Dreams that disturb a person and keep him awake come from the Shaytaan. In general, the dreams that people see are either good dreams which come from Allaah, a reflection of things which a person is thinking about, or a third type, which are dreams that come from the Shaytaan.
It was reported from Abu Hurayrah that the Prophet (peace and blessings of Allaah be upon him) said: Towards the end of time, hardly any dreams that the Muslim sees will not come true. The one whose dreams are the most truthful will be the one whose speech is the most honest.
The dreams of the Muslim form one of the forty-five parts of Prophecy. Dreams are of three types: the good dream which is good news from Allaah; dreams which cause distress, which come from the Shaytaan; and dreams concerning matters which a person is thinking about (Narrated by Muslim, 2263)
The Prophet (peace and blessings of Allaah be upon him) told us how to rid ourselves of the influence of Shaytaan during sleep. This can be achieved by reciting verses from the Quraan and dua narrated from him, before going to sleep. It was reported that Abu Hurayrah (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) put me in charge of guarding the zakaah of Ramadaan. Someone came and started to scatter the food. I took hold of him and said, I will take you to the Messenger of Allaah (peace and blessings of Allaah be upon him).
He said, When you go to bed, recite Aayat al-Kursi and you will be protected by Allaah, and no shaytaan (devil) will come near you until morning. The Prophet (peace and blessings of Allaah be upon him) said, He told you the truth even though he is a liar. That was a shaytaan. (Narrated by al-Bukhaari, 3101).
It was reported that Abu Masood al-Badri (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: The last two aayahs of Soorat al-Baqarah whoever recites them at night, they will be sufficient for him. (Narrated by al-Bukhaari, 3786; Muslim, 807).
Al-Nawawi said: Concerning the phrase, The last two aayahs of Soorat al-Baqarah whoever recites them at night, they will be sufficient for him it was said that it means, they will be sufficient for him instead of praying qiyaam al-layl, or as protection from Shaytaan, or as protection from vermin.
It could mean all of these things. (Sharh Muslim, 6/91, 92). (c) It was reported that Aaïshah (may Allaah be pleased with her) said: When the Messenger of Allaah (peace and blessings of Allaah be upon him) went to his bed, he would blow into his hands and recite Qul Huwa Allaahu Ahad (Soorah 112) and the Miwadhatayn (Soorahs 113 and 114).
Then he would wipe his hands over his face and his body, as far as they could reach Aaishah said: When he fell ill, He would ask me to do that for him. (Narrated by al-Bukhaari, 5416; Muslim, 2192)
The Prophet (peace and blessings of Allaah be upon him) also taught us what to do when someone sees something unpleasant in a dream and wakes up as a result. That is: to spit drily to the left, to seek refuge with Allaah from the Shaytaan, to change the side on which one was sleeping, and to pray if one wishes. It was reported that Abu Qutaadah said: The Prophet (peace and blessings of Allaah be upon him) said: Good dreams come from Allaah and bad dreams come from the Shaytaan. If any one of you sees a bad dream which makes him afraid, let him spit drily to his left and seek refuge with Allaah from its evil, then it will not harm him. (Narrated by al-Bukhaari, 3118; Muslim, 2261).
It was reported from Jaabir that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: If any one of you sees a dream that he dislikes, let him spit drily to his left three time, and seek refuge with Allaah from the Shaytaan three times, and change the side on which he was sleeping. (narrated by Muslim, 2262).
It was reported that Abu Hurayrah said: The Prophet (peace and blessings of Allaah be upon him) said: If any one of you sees something that he dislikes (in a dream), let him get up and pray, and not tell people about it. (narrated by Muslim, 2263) If the Muslim follows this advice given by the Prophet (peace and blessings of Allaah be upon him), before he goes to bed, it is hoped that no shaytaan will come anywhere near him, and if he follows this advice when he wakes up from a bad dream, it will take away all anxiety and distress from him.