The Messenger of Allah ﷺ said, "When one of you sleeps, Satan ties three knots at the back of his head, striking each knot with the words, 'You have a long night ahead, so sleep on.' If he wakes and remembers Allah, one knot is untied. If he performs ablution, another knot is untied. If he prays, all the knots are untied, and he begins his morning energetic and in good spirits. Otherwise, he begins his morning sluggish and in foul spirits."
أخبرنا محمد بن عبد الله بن يزيد قال حدثنا سفيان عن أبي الزناد عن الأعرج
قال رسول الله ﷺ إذا نام أحدكم عقد الشيطان على رأسه ثلاث عقد يضرب على كل عقدة ليلا طويلا أي ارقد فإن استيقظ فذكر الله انحلت عقدة فإن توضأ انحلت عقدة أخرى فإن صلى انحلت العقد كلها فيصبح طيب النفس نشيطا وإلا أصبح خبيث النفس كسلان
Reported by Muslim, Prayer of the Traveler, chapter on the encouragement to pray at night even if only briefly, hadith no. 776, from the narration of Sufyan bin Uyayna. And Bukhari, tahajjud, chapter on the devil tying knots at the back of the head when one does not pray at night, hadith no. 1142, from the narration of Abu Zinad, with the same wording. It is also in Kubra, hadith no. 1301.