كتاب الإيمان
1  
The Book of Faith
(32)
Chapter: Clarifying the Kufr of one who says: "We got rain because of the stars."
(32)
باب بَيَانِ كُفْرِ مَنْ قَالَ مُطِرْنَا بِالنَّوْءِ ‏
Sahih Muslim 71

It is narrated on the authority of Zaid b. Khalid al-Juhani:

The Messenger of Allah (may peace and blessings be upon him) led the morning prayer at Hudaybiya. There were some marks of the rainfall during the night. At the conclusion of prayer he turned towards people and observed: Do you know what your Lord has said? They replied: Allah and His Messenger know best. Upon this he (the Holy Prophet) remarked: He (Allah) said: Some of My bondsmen entered the morning as My believers and some as unbelievers. He who said: We have had a rainfall due to the Blessing and Mercy of Allah, he is My believer and a disbeliever of stars, and who said: We have had a rainfall due to the rising of such and such (star) disbelieved Me and affirmed his faith in the stars.
حَدَّثَنَا يَحْيَى بْنُ يَحْيَى، قَالَ قَرَأْتُ عَلَى مَالِكٍ عَنْ صَالِحِ بْنِ كَيْسَانَ، عَنْ عُبَيْدِ اللَّهِ بْنِ عَبْدِ اللَّهِ بْنِ عُتْبَةَ، عَنْ زَيْدِ بْنِ خَالِدٍ الْجُهَنِيِّ، قَالَ صَلَّى بِنَا رَسُولُ اللَّهِ صلى الله عليه وسلم صَلاَةَ الصُّبْحِ بِالْحُدَيْبِيَةِ فِي إِثْرِ السَّمَاءِ كَانَتْ مِنَ اللَّيْلِ فَلَمَّا انْصَرَفَ أَقْبَلَ عَلَى النَّاسِ فَقَالَ ‏"‏ هَلْ تَدْرُونَ مَاذَا قَالَ رَبُّكُمْ ‏"‏ ‏.‏ قَالُوا اللَّهُ وَرَسُولُهُ أَعْلَمُ ‏.‏ قَالَ ‏"‏ قَالَ أَصْبَحَ مِنْ عِبَادِي مُؤْمِنٌ بِي وَكَافِرٌ فَأَمَّا مَنْ قَالَ مُطِرْنَا بِفَضْلِ اللَّهِ وَرَحْمَتِهِ ‏.‏ فَذَلِكَ مُؤْمِنٌ بِي وَكَافِرٌ بِالْكَوْكَبِ وَأَمَّا مَنْ قَالَ مُطِرْنَا بِنَوْءِ كَذَا وَكَذَا ‏.‏ فَذَلِكَ كَافِرٌ بِي مُؤْمِنٌ بِالْكَوْكَبِ ‏"‏ ‏.‏
Reference : Sahih Muslim 71
In-book reference : Book 1, Hadith 137
USC-MSA web (English) reference : Book 1, Hadith 132
  (deprecated numbering scheme)