The story of magic against the Prophet (peace and blessings of Allaah be upon him) and its meaning
Question

Is the hadith about the magic on Prophet (PBUH) authentic? i've heard alot about this.
Praise be to Allah.The hadeeth of magic against the Prophet (peace and blessings of Allaah be upon him) is a saheeh hadeeth which was narrated by al-Bukhaari, Muslim and other imams of hadeeth. Ahl al-Sunnah accept this story and no one denies it except an innovator. There follows the text of the hadeeth, its source, its meaning and the refutation by the scholars of those who deny it. 
It was narrated that ‘Aa’ishah (may Allaah be pleased with her) said: A spell was put on the Prophet (peace and blessings of Allaah be upon him) until he imagined that he had done a thing when he had not done it. One day he made du’aa’ then he said: “Do you know that Allaah has shown me in what lies my cure? Two men came to me and one of them sat at my head and the other at my feet. One of them said to the other, ‘What is ailing the man?’ He said: ‘He has been bewitched.’ He said: “Who has bewitched him?’ He said: ‘Labeed ibn al-A’sam.’ He said, ‘With what?’ He said: ‘With a comb, the hair that is stuck to it, and the skin of pollen of a male date palm. He said: ‘Where is it?’ He said, ‘In the well of Dharwaan.’” The Prophet (peace and blessings of Allaah be upon him) went out to the well, then he came back and said to ‘Aa’ishah when he came back: “Its date palms are like the heads of devils.” I said: “Did you take it out?” He said: “No. Allaah has healed me, and I feared that that might bring evil upon the people.” Then the well was filled in. 
Narrated by al-Bukhaari, 3268; Muslim, 2189. 
'A comb
and the hairs stuck to it and.' The first one asked, 'Where is that?'
The other replied, '(That is) in the well of Dharwan.' " So
Allah's Apostle along with some of his companions went
there and came back saying, "O 'Aisha, the color of its
water is like the infusion of Henna leaves. The tops of
the date-palm trees near it are like the heads of the
devils." I asked. "O Allah's Apostle? Why did you not
show it (to the people)?" He said, "Since Allah cured me,
I disliked to let evil spread among the people." Then he
ordered that the well be filled up with earth 
Al-Haafiz Ibn Hajar (may Allaah have mercy on him) said: 
Al-Maazari said: The innovators rejected this hadeeth and claimed that it detracted from the status of Prophethood and cast aspersions upon it.  They said: Everything that leads to that is false. And they said that accepting that meant that we could not be sure of the laws that he prescribed, because it is possible that he imagined that he was seeing Jibreel when he was not there, and that something had been revealed to him when nothing had been revealed. Al-Maazari said: All of this is to be rejected, because the evidence that the Prophet (peace and blessings of Allaah be upon him) was truthful in what he conveyed from Allaah and that he was infallible in conveying it is well established. The miracles bear witness to his truthfulness and accepting something when there is evidence to the contrary is false. With regard to some worldly matters for which he was not sent and which have nothing to do with his message, then he was exposed to the same as all other human beings, such as sickness. It is not far-fetched to say that he could be made to imagine something with regard to worldly matters that was not true, whilst at the same time he was protected against such things with regard to matters of religion. 
Some people said that what is meant by this hadeeth is that he (peace and blessings of Allaah be upon him) imagined that he had had intercourse with his wives when he had not done so. This is something that people frequently imagine in their dreams, so it is not far-fetched to say that he could have imagined that when he was awake. 
I – Ibn Hajar – say: This is what is stated clearly in the report of Ibn ‘Uyaynah that is narrated by al-Bukhaari, which says: “until he thought that he had had intercourse with his wives when he had not done so.”  
‘Iyaad said: Thus it is clear that the witchcraft prevailed over his body and physical faculties, not over his discernment and beliefs… 
Al-Mahlab said: The protection of the Prophet (peace and blessings of Allaah be upon him) against the devils does not mean that they would not try to harm him. In al-Saheeh it is narrated that a devil wanted to spoil his prayer but Allaah protected him against him. The same applies to witchcraft; the harm that affected him did not have any impact on his conveying of the message, rather it was akin to any other kind of sickness that afflicted him, such as having difficulty in speaking or doing certain things, or experiencing illusions that did not last. Rather it passed and Allaah foiled the plots of the devils. End quote. 
Fath al-Baari, 10/226, 227 
Ibn al-Qayyim (may Allaah have mercy on him) said: 
How the Prophet (peace and blessings of Allaah be upon him) was guided to treat the spell which Jews cast on him: 
This has been denied by some people who said that this could not have happened to him, and they thought that it was a shortcoming and a fault. But it is not as they think, rather it comes under the heading of sickness and pain that befell him; it is a kind of illness which befell him just as he was also affected by poison – there is no difference between the two. It is proven in al-Saheehayn that ‘Aa’ishah (may Allaah be pleased with her) said: “The Messenger of Allaah (peace and blessings of Allaah be upon him) was bewitched until he thought that he had had intercourse with his wives when he had not done so, and that is the worst kind of witchcraft.” Al-Qaadi ‘Iyaad said: Witchcraft is a kind of sickness which happened to him like other kinds of sickness. That cannot be denied and it does not detract from his Prophethood. 
With regard to his imagining that he had done something when he had not done it, that does not have any impact on his truthfulness, because of the evidence to that effect and the scholarly consensus that he was protected from that. Rather it was one of the matters of this world which are not the reason for which he was sent, and which are not the basis of his virtue and in which he was like all other human beings. It is not far-fetched to say that he might imagine some things that were not real, then things became clear to him later on, as indeed happened. End quote. 
Zaad al-Ma’aad, 4/124 
So it is clear that the hadeeth is saheeh, and that it does not detract from the status of Prophethood. Allaah, may He be glorified and exalted, protected His Prophet (peace and blessings of Allaah be upon him) and made him infallible before this spell was cast, during it and afterwards. The spell did no more than make the Prophet (peace and blessings of Allaah be upon him) think that he had had intercourse with his wives when he had not done so; it had to do with a purely worldly matter, and had nothing to do with his conveying of the message at all. The words of the scholars quoted above are sufficient, and whoever wants to know more may refer to Fath al-Baari and Zaad al-Ma’aad. 
And Allaah knows best.