Huzhaifah and Abu Zharr reported that when the Prophet, peace be upon him, went to bed, he would say, “O Allah, by Your name I live and die.” And when he woke up he said, “Praise be to Allah Who gave us life after death and to Him is the return.” He placed his right hand under his cheek and prayed, three times, “O Allah, save me from Your punishment on the day when You will raise Your creature.”
He would also say, “O Allah, Lord of the heavens, the earth, and the Mighty Throne, our Lord and the Lord of everything, Who causes the seed to grow and the date-stone to split and sprout, Who sent down Taurah, Injil, and the Qur’an, I seek refuge in You from the evil of all evil-mongers under Your Control. You are the First and there is nothing before You, and You are the Last, and there is nothing after You. You are the Evident and there is nothing beyond You, and You are the Source and there is no power beside You. Relieve us of our debt and poverty.” This is reported by Bukhari.
The Prophet, peace be upon him, also prayed, “Praise be to Allah Who has fed us and given us to drink, met all our needs, and given us refuge, while there are many who have neither anyone to meet their needs nor anyone to provide them with a refuge.” And every night when he retired to bed he would hold out his hands together imploringly and blow over them after reciting Surah Al-Ikhlas, Surah Al-Falaq, and Surah An-Nas, and then rub his hands over whichever parts of his body he was able to rub, starting with his head, face, and front of his body. He used to do that three times.
The Prophet, peace be upon him, instructed his Companions that when they go to bed they should supplicate, “In Your name, O Lord, I lay me down to sleep. And by Your leave I raise myself up. So if You take away my soul during sleep, forgive it, and if You keep it alive after sleep protect it just as You protect Your pious servants.”
The Prophet, peace be upon him, once advised his daughter, Fatimah, “Say subhan-Allah thirty three times, al-hamdu-lillah, thirty three times, and Allahu akbar, thirty four times.” He also commended the recitation of ayatal-Kursi, the verse of the Throne, Qur’an 2.255 along with the above supplications, and said that he who does so will be under the protection of Allah, Who will assign a protector to protect him.
The Prophet, peace be upon him, said to Bara, “When you go to bed make wudu as you do for the regular prayer, and then lie down on your right side and say, ‘O Allah, I surrender my soul to You, and I turn my face toward You, and I trust my affairs to Your care. I turn to You in fear and hope. There is no refuge nor any protection against You except in You. I believe in Your book which You have revealed to Your Prophet whom You sent’.” Then he added, “If you die, you will die in your true nature, and these words will be your last words.”