It is narrated from Sayyiduna al-Bara' bin Azib (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) asked (me): "What do you say when you go to your bed?" I said: "Allah and His Messenger know best." He (peace and blessings be upon him) said: "When you lie down on your bed in a state of ablution, make a pillow of your right hand, then say: 'Allahumma inni aslamtu nafsi ilayk, wa wajjahtu wajhi ilayk, wa alja'tu zahri ilayk, rahbatan wa raghbatan ilayk, la malja'a wa la manja minka illa ilayk, amantu bi kitabika al-munzal wa rasulika al-mursal' (O Allah, I have surrendered my soul to You, turned my face towards You, and entrusted my back to Your protection, out of longing for You and fear of You; there is no refuge and no place of safety from You except with You. I believe in Your Book that You sent down and in Your Messenger whom You sent). For any servant who says these words during his night and then his soul is taken, he will die upon the fitrah (the religion of Islam)."
Imam al-Tabarani (may Allah have mercy on him) said: "No one narrated this hadith from Isma'il except Yahya bin Zakariyya al-Ansari."
Hadith Referenceالمعجم الأوسط / باب الألف / 1494
Hadith Takhrij«أخرجه البخاري فى «صحيحه» برقم: 247، 6311، 6313، 6315، 7488، ومسلم فى «صحيحه» برقم: 2710، 2711، وابن خزيمة فى «صحيحه» برقم: 216، وابن حبان فى «صحيحه» برقم: 5522، 5523، 5527، 5536، 5542، والنسائي فى «السنن الكبرى» برقم: 10519، 10520، 10521، 10522، 10525، 10526، 10523، 10527، 10528، 10541، 10540، 10542، 10543، 10544، 10547، 10546، 10545، 10548، 10549، 10553، 10550، 10552، 10551، 10554، 10555، وأبو داود فى «سننه» برقم: 5046، (4/471) [دون رقم في الترقيم المختار]، والترمذي فى «جامعه» برقم: 3394، 3399، 3574، والدارمي فى «مسنده» برقم: 2725، وابن ماجه فى «سننه» برقم: 3876، وأحمد فى «مسنده» برقم: 18764، 18809، 18850، 18858، 18886، 18887، 18902، 18916، 18930، 18950، 18953، 18954، 18955، 18971، 18959، 18980، 18986، 18996، والطيالسي فى «مسنده» برقم: 743، 744، 780، والحميدي فى «مسنده» برقم: 740، وأبو يعلى فى «مسنده» برقم: 1668، 1683، 1711، 1721، وعبد الرزاق فى «مصنفه» برقم: 19829، وابن أبي شيبة فى «مصنفه» برقم: 27051، 27055، 27057، 27063، 27068، 29906، 29907، 29908، 29913، 29923، والطحاوي فى «شرح مشكل الآثار» برقم: 1137، 1136، 1139، 1138، 1140، والترمذي فى «الشمائل» برقم: 254، والطبراني فى «الصغير» برقم: 3، والطبراني فى «الأوسط» برقم: 52، 1248، 1636، 2827، 3429، 6051»