This is the story behind the revelation of al-Mu'awwidhitayn (المعوذتين), the suras of Naas and Falaq. It is interesting to note that superstition and black magic is involved in this explanation of asbaab un-nuzool (reasons for revelation). On immediate reading, it seems astounding that Allah’s Messenger should be the object of black magic and that he should actually accept it as a valid explanation. Should we reject this completely? Additional information here:
Rasulullah had a Jewish servant boy. The Jews approached him and kept after him until he gave them some of Prophet’s fallen hair as well as a few teeth from his comb. The Jews used these to cast a spell of black magic on him.
The person who was behind this was the Jew Labid ibn al-A'sam. He then put the hair in a well belonging to Banu Zurayq called Dharwan. Rasulullah fell ill for a period of six months, during which the hair of his head fell off; he imagined that he slept with his wives when he did not, and was withering away without knowing the reason.
As he was one day sleeping, he saw two angels coming to him. One of them sat at his head and the other at his feet. The angel who sat at his head asked: 'What is wrong with the man?' The second angel responded: 'A spell of black magic was cast on him'. The first one asked: 'And who is responsible for this sorcery?' The second angel answered: 'It is Labid ibn al-A'sam, the Jew'. The first angel asked again: 'What did he use to cast black magic on him?' The second angel said: 'He used a comb and fallen hair'. The first angel asked: 'Where is it now?' The second angel said: 'It is inside the spadix of a palm tree beneath the stepping stone which is inside the well of Dharwan', at which point Rasulullah woke up.
He said: 'O 'A'ishah, do you not think that this is from Allah to inform me of the cause of my illness?' He then sent 'Ali [ibn Abi Talib], al-Zubayr [ibn al-'Awwam] and 'Ammar [ibn Yasir] who drained the water of that well as one would drain the dust of henna. They lifted the stone and got the spadix out and found therein some of the hair of Rasulullah as well a few teeth from his comb.
They also found with it a string with eleven knots knitted with needles. Allah, exalted is He, then revealed Surah al-Falaq and Surah al-Nas (al-Mu'awwidhatayn). With each verse that Rasulullah read one knot was untied and the Prophet felt some lightness. When the last knot was untied, the Prophet got up as if he was released from a cord to which he was tied up. Gabriel, peace be upon him, kept saying: 'In the name of Allah I cast this incantation on you to protect you from anything that might harm you and that Allah heals you from the resentful envier and the evil eye'. Those around him said: 'O Messenger of Allah, should we not head toward that evil person and kill him?' He said: 'As for me, Allah has cured me, and I dislike causing evil to other people'. This is of the forbearance of the Messenger of Allah, Allah bless him and give him peace”.
A'ishah said: “A spell of black magic was cast on the Prophet such that he used to imagine that he did things when he did not. He was at my place, one day, and he began imploring Allah in earnest. Then he said: 'Did you not feel, O 'A'ishah, that Allah has answered me about that which I have enquired?' I said: 'And what is that, O Messenger of Allah?' He said: 'Two angels came to me…', and he mentioned the whole story”.
The whole story is narrated by Bukhari from 'Ubayd ibn Isma'il from Abu Usamah. The same narration has different channels of transmission in both the authentic collections of Bukhari and Muslim.