The Messenger of Allah ﷺ said, "When one of you sees a dream he dislikes, let him spit to his left three times, seek refuge with Allah from Satan three times, and turn over from the side he was lying on."
عن رسول الله ﷺ أنه قال: إذا رأى أحدكم الرؤيا يكرهها فليبصق عن يساره ثلاثا، وليستعذ بالله من الشيطان ثلاثا، وليتحول عن جنبه الذي كان عليه.
Muslim narrated it in the Book of Dreams (2262) through the route of Layth, from Abu Zubayr, from Jabir bin Abdullah, who reported it. Imam Ahmad also narrated it (15110) from Rawh, who said, Zakariya bin Ishaq narrated to us, saying, Abu Zubayr narrated to us, that he heard Jabir bin Abdullah say, A man came to the Prophet ﷺ and said, "O Messenger of Allah, I saw in a dream that my head was cut off and was rolling away while I followed it." The Messenger of Allah ﷺ said, "That is from Satan. If any of you sees a dream he dislikes, he should not relate it to anyone, and he should seek refuge with Allah from Satan." Its isnad is sahih.