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

It is reported on the authority of Ibn 'Abbas that there was (once) a downpour during the life of the Apostle (may peace and blessings be upon him Upon this the Apostle (may peace and blessings be upon him) observed:

Some people entered the morning with gratitude and some with ingratitude (to Allah). Those who entered with gratitude said: This is the blessing of Allah, and those who entered with ingratitude said: Such and such asterism was right. It was upon this that the verse was revealed: I swear by the setting of the stars to the end and make your provision that you should disbelieve it.
وَحَدَّثَنِي عَبَّاسُ بْنُ عَبْدِ الْعَظِيمِ الْعَنْبَرِيُّ، حَدَّثَنَا النَّضْرُ بْنُ مُحَمَّدٍ، حَدَّثَنَا عِكْرِمَةُ، - وَهُوَ ابْنُ عَمَّارٍ - حَدَّثَنَا أَبُو زُمَيْلٍ، قَالَ حَدَّثَنِي ابْنُ عَبَّاسٍ، قَالَ مُطِرَ النَّاسُ عَلَى عَهْدِ النَّبِيِّ صلى الله عليه وسلم فَقَالَ النَّبِيُّ صلى الله عليه وسلم ‏"‏ أَصْبَحَ مِنَ النَّاسِ شَاكِرٌ وَمِنْهُمْ كَافِرٌ قَالُوا هَذِهِ رَحْمَةُ اللَّهِ ‏.‏ وَقَالَ بَعْضُهُمْ لَقَدْ صَدَقَ نَوْءُ كَذَا وَكَذَا ‏"‏ ‏.‏ قَالَ فَنَزَلَتْ هَذِهِ الآيَةُ ‏{‏ فَلاَ أُقْسِمُ بِمَوَاقِعِ النُّجُومِ‏}‏ حَتَّى بَلَغَ ‏{‏ وَتَجْعَلُونَ رِزْقَكُمْ أَنَّكُمْ تُكَذِّبُونَ‏{‏
Reference : Sahih Muslim 73
In-book reference : Book 1, Hadith 140
USC-MSA web (English) reference : Book 1, Hadith 135
  (deprecated numbering scheme)