Praise be to Allah.
It was proven in a saheeh hadeeth (authentic narration) that this witchcraft took place in Madeenah, when the revelation and the message had become well-established and clear, and after the evidence of Prophethood and the truthfulness of the message had been confirmed, and after Allah had supported His Prophet (peace and blessings of Allah be upon him) against the mushrikeen and humiliated them. Then a Jewish person called Labeed ibn al-A’asam came to him and did some kind of witchcraft against him, using a comb and the hairs stuck to it and the skin of pollen of a male date palm. He – the Prophet (peace and blessings of Allah be upon him) – started to imagine that he had done something with his wife when he had not done it, but his reason, feelings and ability to distinguish matters remained with him with regard to the things he was telling the people, praise be to Allah. So he continued to speak to the people of the truth which Allah had revealed to Him. But he felt that something was affecting him with regard to his wives, as ‘Aishah (may Allah be pleased with her) said: “He used to imagine that he had done something in the house with his wife when he had not done it. So revelation came to him from his Lord via Jibreel (peace be upon him), telling him what had happened. So he sent someone to take that thing [the material used for witchcraft purposes] out of the well of one of the Ansar (inhabitants of Madeenah who welcomed emigrants from makkah), and he destroyed it.” Then the effects of that left him, praise be to Allah, and Allah revealed to him the two surahs of seeking refuge with Allah (al-Mu’awwadhatayn, the last two surahs of the Quran). He recited them and all harm left him. The Prophet (peace and blessings of Allah be upon him) said: “Those who seek refuge can never seek refuge with anything like them.” Nothing resulted from this witchcraft that could have harmed the people or undermined the message or revelation. Allah protected him from the people with regard to the matter of receiving and conveying the message.
But with regard to the kinds of harm that befell the Messengers, he (peace and blessings of Allah be upon him) was not protected from them, rather some such things befell him too. He was wounded on the day of Uhud, and his helmet was smashed on his head and his cheek was cut, some of the rings from his chain mail pierced his cheeks, he fell in one of the holes that were there, and they subjected him to intense persecution in Makkah. He suffered some of the things that the Messengers before him had suffered, and that were decreed for him, by means of which Allah raised him in status and multiplied his hasanat (reward for good deeds). But Allah protected him from them, so that they were not able to kill him or to prevent him from conveying the Message; they were not able to prevent him from fulfilling his obligation to convey the message, so he conveyed it and fulfilled the mission with which he had been entrusted. May the peace and blessings of Allah be upon him, and praise be to Allah, the Lord of the Worlds.
And Allah knows best.