The Messenger of Allah ﷺ said, "Satan ties three knots at the back of the head of each one of you when he sleeps. At each knot he strikes the spot, saying, 'You have a long night ahead, so sleep on.' If the person 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 sluggish."
أن رسول الله ﷺ قال: يعقد الشيطان على قافية رأس أحدكم إذا هو نام ثلاث عقد. يضرب مكان كل عقدة: عليك ليل طويل فارقد. فإن استيقظ فذكر الله انحلت عقدة، فإن توضأ انحلت عقدة، فإن صلى انحلت عقده. فأصبح نشيطا طيب النفس، وإلا أصبح خبيث النفس كسلان.
Malik reported it in the Shortening of Prayer (95) from Abu Zinad, from Araj, from Abu Hurairah, and he mentioned the hadith. Bukhari reported it in Tahajjud (1142) through the route of Malik, similarly.Muslim reported it in the Prayer of Travelers (776) from the hadith of Sufyan bin Uyayna, from Abu Zinad, and in it, "When he performs wudu, two knots are undone. When he prays, the knots are undone."