According to Islam's most trusted sources, Muhammad was a victim of a magic spell, which gave him delusional thoughts and false beliefs. Consider two ahadith:
Sahih Al-Bukhari 3175—Aisha narrated: "Once the Prophet was bewitched so that he began to imagine that he had done a thing which in fact, he had not done."
Sahih Al-Bukhari 5765—Aisha narrated: Magic was worked on Allah's Apostle so that he used to think that he had had sexual relations with his wives while he actually had not. Then one day he said, "O Aisha, do you know that Allah has instructed me concerning the matter I asked Him about? Two men came to me and one of them sat near my head and the other sat near my feet. The one near my head asked the other: 'What is wrong with this man?' The latter replied, 'He is under the effect of magic.' The first one asked, 'Who has worked magic on him?' The other replied, 'Labid bin Al-Asam, a man from Bani Zuraiq who was an ally of the Jews and was a hypocrite.' The first one asked, 'What material did he use?' The other replied, 'A comb and the hair stuck to it.'"
Apart from the most obvious problem for Muslims (namely, how anyone can fully trust a man who was controlled by a magic spell), there is a deeper difficulty. According to Qur'an 2:102, magic comes from demons. According to Qur'an 16:98-100, Satan has no power over those "who believe and put trust in their Lord," but only over those "who make a friend of him, and those who ascribe partners unto Him (Allah)." So if Satan only has power over those who befriend him and commit shirk, and black magic is demonic power over human beings, and Muhammad was a victim of black magic, then Muhammad, according to the Qur'an, must have been a friend of Satan who committed shirk!
For more on this issue, see Sam Shamoun's article, "Was Muhammad Protected from the Power of Satan?"