Sunan Abi Dawud, Hadith 1301

Narrated Abu Hurairah: The Messenger of Allah as saying: When one you sleeps, the devil ties three knots at the back of his neck, sealing every knot with, "You have a long night, so sleep." So if one awakes and mentions Allah, a knot will be loosened; if he performs ablution another knot will be loosened; and if he prays, the third knot will be loosened; and in the morning he will be active and in good spirits; otherwise he will be in bad spirits and sluggish.

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مَسْلَمَةَ، عَنْ مَالِكٍ، عَنْ أَبِي الزِّنَادِ، عَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ يَعْقِدُ الشَّيْطَانُ عَلَى قَافِيَةِ رَأْسِ أَحَدِكُمْ إِذَا هُوَ نَامَ ثَلاَثَ عُقَدٍ يَضْرِبُ مَكَانَ كُلِّ عُقْدَةٍ عَلَيْكَ لَيْلٌ طَوِيلٌ فَارْقُدْ فَإِنِ اسْتَيْقَظَ فَذَكَرَ اللَّهَ انْحَلَّتْ عُقْدَةٌ فَإِنْ تَوَضَّأَ انْحَلَّتْ عُقْدَةٌ فَإِنْ صَلَّى انْحَلَّتْ عُقْدَةٌ فَأَصْبَحَ نَشِيطًا طَيِّبَ النَّفْسِ وَإِلاَّ أَصْبَحَ خَبِيثَ النَّفْسِ كَسْلاَنَ ‏" ‏ ‏.‏

sunnah.com