Sunan Ibn Majah, Book 35, Hadith 17 (In-Book) ⓘ
It was narrated from Abu Qatadah that the Messenger of Allah said: “(Good) dreams come from Allah and (bad) dreams come from Satan, so if anyone of you sees something that he dislikes, let him spit dryly to his left three times, and seek refuge with Allah from the accursed Satan three times, and turn over onto his other side.”
حَدَّثَنَا مُحَمَّدُ بْنُ رُمْحٍ، حَدَّثَنَا اللَّيْثُ بْنُ سَعْدٍ، عَنْ يَحْيَى بْنِ سَعِيدٍ، عَنْ أَبِي سَلَمَةَ بْنِ عَبْدِ الرَّحْمَنِ بْنِ عَوْفٍ، عَنْ أَبِي قَتَادَةَ، أَنَّ رَسُولَ اللَّهِ ـ صلى الله عليه وسلم ـ قَالَ " الرُّؤْيَا مِنَ اللَّهِ وَالْحُلْمُ مِنَ الشَّيْطَانِ فَإِنْ رَأَى أَحَدُكُمْ شَيْئًا يَكْرَهُهُ فَلْيَبْصُقْ عَنْ يَسَارِهِ ثَلاَثًا وَلْيَسْتَعِذْ بِاللَّهِ مِنَ الشَّيْطَانِ الرَّجِيمِ ثَلاَثًا وَلْيَتَحَوَّلْ عَنْ جَنْبِهِ الَّذِي كَانَ عَلَيْهِ " .
also referenced under: Hadith 3909 (Reference) & Volume 5, Book 35, Hadith 3909 (DarusSalam)