The Prophet ﷺ said, "No man acquires a branch of knowledge from the stars except that he has acquired thereby a branch of magic. The more he learns of it, the more sin he gains."
عن النبي ﷺ قال: ما اقتبس رجل علما من النجوم إلا اقتبس بها شعبة من السحر، ما زاد زاد.
Reported by Abu Dawud (3905), Ibn Majah (3726), and Ahmad (2000), all from the hadith of Yahya bin Saeed, from Ubaydullah bin Akhnas, from Walid bin Abdullah, from Yusuf bin Mahak, from Ibn Abbas, who related it. Its isnad is sahih. Ubaydullah bin Akhnas Nakhai is trustworthy, having been deemed so by Ahmad, Ibn Main, Abu Dawud, Nasai, and others, though Hafiz said, "Truthful," and Ibn Hibban said, "He used to err."The legal understanding of this chapter is that these hadiths, which state that the Prophet ﷺ was indeed bewitched, do not contradict what is stated in the Quran, "The wrongdoers say, 'You are only following a man who is bewitched'" [Isra 17:47] and "The wrongdoers say, 'You are only following a man who is bewitched'" [Furqan 25:8]. This is because the Prophet ﷺ was protected by Allah, the Exalted, in receiving and conveying the revelation. Quraysh used to hurl accusations at him, calling him a sorcerer, bewitched, insane, a liar, and a poet, but all these accusations are false. For this reason, Allah responded to them by saying, "See how they describe you, and so they have gone astray and cannot find a way" [Furqan 25:9].As for the sorcery by which the Prophet ﷺ was bewitched, it was related only to his worldly affairs. For example, he ﷺ would imagine that he had eaten when he had not eaten, and he would imagine that he had come to his wife when he had not come to her, and this was due to the nature of human frailty.