كتاب الذكر والدعاء والتوبة والاستغفار
48  
The Book Pertaining to the Remembrance of Allah, Supplication, Repentance and Seeking Forgiveness
(17)
Chapter: Supplication When Going To Sleep
(17)
باب مَا يَقُولُ عِنْدَ النَّوْمِ وَأَخْذِ الْمَضْجَعِ
Sahih Muslim 2712

Abdullah b. 'Umar commanded a person that as he went to bed, he should say:

" O Allah, Thou created my being and it is for Thee to take it to its ultimate goal. And its death and life is due to Thee, and if Thou givest it life, safeguard it; and if Thou bringst death, grant it pardon. O Allah, I beg of Thee safety." A person said to him: Did you hear it from Umar? Thereupon he said: (I have heard from one) who is better than Umar, viz. from Allah's Messenger (ﷺ). Ibn Nafi, reported this on the authority of Abdullah b. Harith but he did not make mention of this" that he heard it himself".
حَدَّثَنَا عُقْبَةُ بْنُ مُكْرَمٍ الْعَمِّيُّ، وَأَبُو بَكْرِ بْنُ نَافِعٍ قَالاَ حَدَّثَنَا غُنْدَرٌ، حَدَّثَنَا شُعْبَةُ، عَنْ خَالِدٍ، قَالَ سَمِعْتُ عَبْدَ اللَّهِ بْنَ الْحَارِثِ، يُحَدِّثُ عَنْ عَبْدِ اللَّهِ بْنِ عُمَرَ، أَنَّهُ أَمَرَ رَجُلاً إِذَا أَخَذَ مَضْجَعَهُ قَالَ ‏ "‏ اللَّهُمَّ خَلَقْتَ نَفْسِي وَأَنْتَ تَوَفَّاهَا لَكَ مَمَاتُهَا وَمَحْيَاهَا إِنْ أَحْيَيْتَهَا فَاحْفَظْهَا وَإِنْ أَمَتَّهَا فَاغْفِرْ لَهَا اللَّهُمَّ إِنِّي أَسْأَلُكَ الْعَافِيَةَ ‏"‏ ‏.‏ فَقَالَ لَهُ رَجُلٌ أَسَمِعْتَ هَذَا مِنْ عُمَرَ فَقَالَ مِنْ خَيْرٍ مِنْ عُمَرَ مِنْ رَسُولِ اللَّهِ صلى الله عليه وسلم ‏.‏ قَالَ ابْنُ نَافِعٍ فِي رِوَايَتِهِ عَنْ عَبْدِ اللَّهِ بْنِ الْحَارِثِ ‏.‏ وَلَمْ يَذْكُرْ سَمِعْتُ ‏.‏
Reference : Sahih Muslim 2712
In-book reference : Book 48, Hadith 81
USC-MSA web (English) reference : Book 35, Hadith 6550
  (deprecated numbering scheme)