David also extended her record of world titles to eight with her 5-11, 11-8, 7-11, 14-12, 11-5 win.
But she but had to recover from a game and 2-6 down, from 6-10 down in the fourth game, and from El Weleily's constantly dynamic attacks, fuelled by the energy from a noisy partisan home crowd.
"I don't know what to feel actually," said David afterwards. "You work so hard and when the final plays out like this you don't know what to do with yourself — but I am so very happy.
"There were moments when I thought it could be over, but I didn't want it to end that way. I dug very deep, because I wanted it badly.
"Raneem is so strong, and I knew that if I didn't do something about it she would take it. I wanted to make it happen, so, yes there was a change of emphasis in the way I played.
El Weleily acknowledged the surprising way in which David had rescued her title. "There will be lots of positives to take from my performance," she said. "I just won't be taking them today, that's all.”
"I had to do something about what happened — and I didn't. I can perhaps be a champion in the future but I will need to learn a lot," added the 25-year-old.
Like Sports on Facebook, follow @ETribuneSports on Twitter to stay informed and join in the conversation.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ