The Messenger of Allah ﷺ said, "Satan ties three knots at the back of the head of one of you when he sleeps, striking each knot with the words, 'You have a long night ahead, so sleep on.' If he wakes and remembers Allah, one knot is undone. If he performs ablution, another knot is undone. If he prays, the last knot is undone, and he begins his morning energetic and in good spirits. Otherwise, he wakes up ill-tempered and lazy."
حدثنا عبد الله بن مسلمة عن مالك عن أبي الزناد عن الأعرج
أن رسول الله ﷺ قال يعقد الشيطان على قافية رأس أحدكم إذا هو نام ثلاث عقد يضرب مكان كل عقدة عليك ليل طويل فارقد فإن استيقظ فذكر الله انحلت عقدة فإن توضأ انحلت عقدة فإن صلى انحلت عقدة فأصبح نشيطا طيب النفس وإلا أصبح خبيث النفس كسلان
Reported by Bukhari, in the chapter on tahajjud, section titled "The devil ties a knot at the back of the head when one does not pray at night," hadith no. 1142, from the hadith of Malik, and by Muslim, in the chapter on the prayer of travelers, section titled "Encouragement to pray at night even if only briefly," hadith no. 776, from the hadith of Abu Zinad through the same chain. It is also found in Muwatta (Yahya), 1/176 (and Qanabi, pp. 109, 110).