Mishkat al-Masabih
Mishkat al-Masabih 1520
وَعَنْ عَائِشَةَ رَضِيَ اللَّهُ عَنْهَا قَالَتْ: كَانَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ إِذَا أَبْصَرْنَا شَيْئًا مِنَ السَّمَاءِ تَعْنِي السَّحَابَ تَرَكَ عَمَلَهُ وَاسْتَقْبَلَهُ وَقَالَ: «اللَّهُمَّ إِنِّي أَعُوذُ بِكَ مِنْ شَرِّ مَا فِيهِ» فَإِنْ كَشَفَهُ حَمِدَ الله وَإِن مطرَت قَالَ: «اللَّهُمَّ سَقْيًا نَافِعًا» . رَوَاهُ أَبُو دَاوُدَ وَالنَّسَائِيُّ وَابْنُ مَاجَه وَالشَّافِعِيّ وَاللَّفْظ لَهُ
Aisha, may God be pleased with her, said: When the Prophet saw something in the sky—we mean clouds—he left what he was doing, turned toward it, and said: O God, I seek refuge in You from the evil it contains. If He cleared it away, he praised God; if it rained, he said: O God, grant beneficial rain.
Abu Dawud, al-Nasai, Ibn Majah, and al-Shafii transmitted it; the wording is al-Shafii version.