Abu Ishaq al-Hamdani (may Allah have mercy on him) narrates from his father that he said: Sayyiduna Ali bin Abi Talib (may Allah be pleased with him) wrote something for me and said: "The Prophet (peace and blessings be upon him) commanded me with it; he (peace and blessings be upon him) said: 'When you lie down on your bed, say: A'udhu bi-wajhillahil-karim, wa kalimatihit-tammah, min sharri ma anta akhidhun bi-nasiyatih; Allahumma anta takshiful-maghrama wal-ma'tham; Allahumma la tahzim jundak, wa la tukhlif wa'dak, wa la yanfa'u dhal-jaddi minkal-jadd; subhanaka wa bihamdik (I seek refuge in the Noble Face of Allah and in His perfect words from the evil of everything whose forelock You hold; O Allah, You remove debt and sin; O Allah, Your army cannot be defeated, and You do not break Your promise, and the fortune of a man of fortune cannot avail him against You; You are free of all imperfection, and (I praise You) with Your praise).'"
Abu Ishaq (may Allah have mercy on him) said: I mentioned this to Abu Maysarah al-Hamdani (may Allah have mercy on him), and he narrated to me something similar from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him), except that he said: 'min sharri ma anta batishun bi-nasiyatih' (from the evil of everything whose forelock You seize (in Your grip)).
Hadith Referenceالمعجم الأوسط / باب الميم / 6779
Hadith Takhrij«أخرجه الضياء المقدسي فى «الأحاديث المختارة» برقم: 700، 701، والنسائي فى «السنن الكبرى» برقم: 7685، 10535، وأبو داود فى «سننه» برقم: 5052، والطبراني فى «الصغير» برقم: 998»