The Prophet ﷺ said, "No one acquires a branch of knowledge from the stars except that he has acquired a branch of magic. The more he learns of the one, the more he gains of the other."
حدثنا يحيى عن عبيد الله بن الأخنس قال حدثنا الوليد بن عبد الله عن يوسف بن ماهك
عن النبي ﷺ قال ما اقتبس رجل علما من النجوم إلا اقتبس بها شعبة من السحر ما زاد زاد
Its chain of transmission is sahih. Ubaydullah bin Akhnas al-Kufi al-Khazzaz, with the dotted letters, is trustworthy. Ahmad, Ibn Main, Abu Dawud, and Nasai all deemed him trustworthy. Walid bin Abdullah bin Abu Mughith is from the Hijaz. Ibn Main and Ibn Hibban deemed him trustworthy, and Bukhari mentioned him in al-Kabir, 2/4/146.The hadith appears in Targhib wal-Tarhib, 4:53, where it says, "Abu Dawud, Ibn Majah, and others narrated it." Khattabi said in al-Maalim, 4:229-230, "The knowledge of the stars that is prohibited is what the astrologers claim regarding knowledge of future events and occurrences that have not yet happened but will happen in the future, such as their claims to inform about the timing of winds blowing, rain coming, heat and cold appearing, and changes in prices, and similar matters, which they claim to know through the movement of the stars in their courses, and through their conjunctions and alignments. They claim that these have an influence over earthly affairs, or that earthly affairs are governed by their rulings and follow the dictates of their determinations. This is, on their part, a presumptuous claim over the unseen, and an attempt to lay hold of knowledge that Allah has reserved exclusively for Himself, for no one knows the unseen except Him.As for the knowledge of the stars that can be perceived through observation and the senses, by which the time of midday is known and the direction of the qibla is determined, this is not included in what is prohibited. This is because the knowledge gained from observing shadows is nothing more than this, as long as the shadow is decreasing, the sun is still rising toward the middle of the sky from the eastern horizon, and once it begins to increase, the sun is descending from the middle of the sky toward the western horizon. This is knowledge whose acquisition through observation is valid, except that the practitioners of this craft have refined it by devising instruments that spare the observer from having to track its duration and monitor it directly.As for what is deduced from the stars regarding the direction of the qibla, these are simply stars that were observed by people with expertise in them, from among the leading scholars whose concern for matters of religion, whose knowledge of these stars, and whose truthfulness in what they reported about them we do not doubt, such that they observed them in the presence of the Kaaba and observed them while absent from it. Their own perception of this indication came through direct observation, while our perception of it comes through our acceptance of their report, since they were not suspected of dishonesty in their religion, nor were they deficient in their knowledge."This will come again at 2841.