We believe that Allah created the stars and planets for wise purposes, one of which is mentioned in the verse that reads: {And landmarks and the stars by which they find their way.} [Surat an-Nahl: 16] Qatādah (may Allah have mercy upon him) said: "Allah Almighty created these stars for three purposes: an adornment for the sky, a means whereby people can know their way, and missiles that stone the devils. Whoever deals with the stars for other purposes has deviated from the true way and lost the good fortune and share, and has thus engaged in something he has no knowledge about." [Tafsīr At-Tabari (17/185)]
Abu Mūsa (may Allah be pleased with him) reported: We offered the Maghrib prayer along with the Messenger of Allah (may Allah’s peace and blessings be upon him). We then said: "What if we sit and observe the ‘Ishā’ prayer with him." So, we sat down, and he came to us and said: "You are still sitting here." We said: "O Messenger of Allah, we observed the Maghrib prayer with you and then said: 'Let us sit down and observe the ‘Ishā’ prayer along with you.'" Thereupon, he said: "You have done well or you have done right." He then turned his head toward the sky - and he would often turn his head toward the sky - and said: "The stars are a source of security for the sky, and when the stars disappear, there will come to the sky what it has been promised. And I am a source of security for my Companions, and when I go away, there will come to my Companions what they have been promised. And my Companions are a source of security for my Ummah, and when my Companions go away, there will come to my Ummah what they have been promised." [Narrated by Muslim (2531)]
And Allah Almighty says: {We have adorned the lowest heaven with lamps and have made them as missiles to stone the devils.} [Surat al-Mulk: 5]
Ibn ‘Abbās (may Allah be pleased with him) reported: One of the Prophet's Companions from the Ansār told me that while they were sitting one night along with the Messenger of Allah (may Allah’s peace and blessings be upon him), a star was thrown and shone brightly. He asked them: "What would you say in jāhiliyyah (the pre-Islamic period of ignorance) when something of that nature was thrown." They replied: "Allah and His Messenger know best. We used to say that a great man had been born that night, or that a great man had died." Thereupon, the Messenger of Allah (may Allah's peace and blessings be upon him) said: "It is not thrown because of anyone’s death or life; but when our Lord, Blessed and Exalted be He, decrees a matter, the bearers of the Throne glorify Him; then the inhabitants of heaven who are next to them glorify Him, till the glorification reaches the inhabitants of this worldly heaven. Then, those who are near the bearers of the Throne ask them: 'What has your Lord said?' They tell them what He has said. Then, the inhabitants of the heavens ask one another till it reaches this worldly heaven. Then, the jinn snatch a hearing and pass it on to their friends and have [flames] thrown at them. What they bring as it is is true, but they mix things with it and make additions." [Narrated by Muslim (2229)]
The devils used to eavesdrop, but when Prophet Muhammad (may Allah’s peace and blessings be upon him) was sent with the message, they were denied their positions of eavesdropping. A Qur'anic verse says: {We used to take up positions there for eavesdropping, but now anyone who eavesdrops will find a flaming fire waiting for him.} [Surat al-Jinn: 9] Other verses read: {We have adorned the sky with the beauty of the stars, and for safeguarding it against every rebellious devil, so that they cannot eavesdrop on the highest assembly [of angels] and are pelted from every side to repel them; and for them there will be a perpetual punishment, except who stealthily snatches away some words, he will be pursued by a piercing flame.} [Surat as-Sāffāt: 6-10]
Ibn ‘Abbās (may Allah be pleased with him) reported: The jinn used to ascend through the heavens, trying to overhear the revelation. When they heard a word, they would add nine words to it. The word they heard would be true, while what they added was false. When the Messenger of Allah (may Allah’s peace and blessings be upon him) was sent, they were denied their positions. They mentioned that to Satan – and the stars were not shot at them before that. Satan said to them: "This is nothing but an event that has occurred on earth." He sent out his armies, and they found the Messenger of Allah standing in prayer between two mountains – I think he said "in Makkah" – and they returned and met him and informed him about that. Thereupon, he said: "This is the event that has happened on earth." [Narrated by At-Tirmidhi (3324), Ahmad (2482), An-Nasā’i in Al-Kubra (11562), and Abu Ya‘la (2502)]
We believe that the stars and planets do not render benefit or cause harm or have any impact on terrestrial or celestial events. Whoever thinks that they have impact per se has thus become a disbeliever or a polytheist. Ibn ‘Abbās (may Allah be pleased with him) reported: People had a rainfall during the Prophet's lifetime. Thereupon, he said: "This morning some people are grateful and others are ungrateful." They said: "This is the mercy of Allah. And some of them said: "The rise of such and such a star has been true." So, this verse was revealed: {I do swear by the positions of the stars... And instead [of thanking Allah] for the provision you are given, you show ingratitude?} [Surat al-Wāqi‘ah: 75-82] [Narrated by Muslim (73)]
The Messenger of Allah (may Allah's peace and blessings be upon him) said: "The thing I fear most for my Ummah in their latter time is belief in the stars, denial of destiny, and injustice of the ruler." [Narrated by Ar-Rawyāni (1245) and At-Tabarāni in Al-Kabīr (8113)]
The Prophet (may Allah’s peace and blessings be upon him) forbade astrology. In a Hadīth, he said: "Whoever acquires any knowledge of astrology does acquire a branch of magic, of which he gets more as long as he continues to do so." [Narrated by Abu Dāwūd (3905), Ibn Mājah (3726), Ibn Abi Shaybah (26159), Ahmad (2000), and ‘Abd ibn Humayd (714)]
So, it is not permissible to acquire knowledge of the stars except within the limits needed for guidance in the land and sea. This is because studying them leads to divination. Sa‘īd ibn Jubayr reported: A man came to ‘Abdullāh ibn ‘Abbās and said: "O Abu ‘Abbās, advise me." He said: "I advise you to fear Allah. Beware of speaking badly about the Prophet's Companions, for you do not know how they excelled in merit. Beware of the work of the stars (astrology), except to the extent needed for guidance in the land or sea, for it leads to divination. And beware of sitting with those who deny destiny. Whoever likes that his supplication be answered and his deeds purified and accepted from him should be truthful in speech, fulfill his trust, and have good feelings toward Muslims." [Narrated by Ibn Battah in Al-Ibānah (1987)]