We set out with the Messenger of Allah ﷺ during the year of Hudaybiyyah, and one night rain fell upon us. The Messenger of Allah ﷺ led us in the dawn prayer, then turned to us and said, "Do you know what your Lord has said?"We replied, "Allah and His Messenger know best."He said, "Allah said, 'This morning some of My servants have become believers in Me and others disbelievers. Whoever said, We have been given rain by the mercy of Allah, by the provision of Allah, and by the bounty of Allah, is a believer in Me and a disbeliever in the stars. But whoever said, We have been given rain by such-and-such a star, is a believer in the stars and a disbeliever in Me.'"
خرجنا مع رسول الله ﷺ عام الحديبية، فأصابنا مطر ذات ليلة فصلى لنا رسول الله ﷺ صلاة الصبح ثم أقبل علينا فقال: أتدرون ماذا قال ربكم؟ قلنا: الله ورسوله أعلم، فقال: قال الله: أصبح من عبادي مؤمن بي وكافر بي، فأما من قال: مطرنا برحمة الله وبرزق الله، وبفضل الله، فهو مؤمن بي، كافر بالكواكب، وأما من قال: مطرنا بنجم كذا وكذا، فهو مؤمن بالكواكب كافر بي.
Bukhari narrated it in the Book of Military Expeditions (4147) and Muslim in the Book of Faith (71:125), both through Salih bin Kaysan, from Ubaydullah bin Abdullah, from Zayd bin Khalid , who said, and he related it.