“Allah says, ‘In this morning some of My worshipers remained as true believers and some became non-believers; he who said that it had rained with the blessing and mercy of Allah is the one who believes in Me and does not believe in star, but he who said it had rained because of such and such (star) is a disbeliever in Me and is a believer in star.’ ”

حَدَّثَنَا إِسْمَاعِيلُ، حَدَّثَنِي مَالِكٌ، عَنْ صَالِحِ بْنِ كَيْسَانَ، عَنْ عُبَيْدِ اللَّهِ بْنِ عَبْدِ اللَّهِ بْنِ عُتْبَةَ بْنِ مَسْعُودٍ، عَنْ زَيْدِ بْنِ خَالِدٍ الْجُهَنِيِّ، أَنَّهُ قَالَ صَلَّى لَنَا رَسُولُ اللَّهِ صلى الله عليه وسلم صَلاَةَ الصُّبْحِ بِالْحُدَيْبِيَةِ عَلَى إِثْرِ سَمَاءٍ كَانَتْ مِنَ اللَّيْلَةِ، فَلَمَّا انْصَرَفَ النَّبِيُّ صلى الله عليه وسلم أَقْبَلَ عَلَى النَّاسِ فَقَالَ ‏”‏ هَلْ تَدْرُونَ مَاذَا قَالَ رَبُّكُمْ ‏”‏‏.‏ قَالُوا اللَّهُ وَرَسُولُهُ أَعْلَمُ‏.‏ قَالَ ‏”‏ أَصْبَحَ مِنْ عِبَادِي مُؤْمِنٌ بِي وَكَافِرٌ، فَأَمَّا مَنْ قَالَ مُطِرْنَا بِفَضْلِ اللَّهِ وَرَحْمَتِهِ‏.‏ فَذَلِكَ مُؤْمِنٌ بِي كَافِرٌ بِالْكَوْكَبِ، وَأَمَّا مَنْ قَالَ بِنَوْءِ كَذَا وَكَذَا‏.فَذَلِكَ كَافِرٌ بِي مُؤْمِنٌ بِالْكَوْكَبِ ‏”‏‏.‏

Narrated Zaid bin Khalid Al-Juhani:

Allah’s Messenger (ﷺ) led the morning prayer in Al-Hudaibiya and it had rained the previous night. When the Prophet (ﷺ) (p.b.u.h) had finished the prayer he faced the people and said,

“Do you know what your Rabb has said?”

They replied, “Allah and His Apostle know better.”

(The Prophet (ﷺ) said), “Allah says, ‘In this morning some of My worshipers remained as true believers and some became non-believers; he who said that it had rained with the blessing and mercy of Allah is the one who believes in Me and does not believe in star, but he who said it had rained because of such and such (star) is a disbeliever in Me and is a believer in star.’ ”

Sahih Bukhari
Reference: Sahih al-Bukhari 1038 (Invoking Allah for Rain (Istisqaa))

Reference  : Sahih al-Bukhari 1038
In-book reference  : Book 15, Hadith 33
USC-MSA web (English) reference  : Vol. 2, Book 17, Hadith 148
  (deprecated numbering scheme)