Reference: Fataawa al-Lajnah ad-Daa.imah lil-Buhooth al-‘Ilmiyyah wal-Iftaa. – Fatwa No.9437
Fataawa Ramadhaan – Volume 2, Page 527, Fatwa No.495
Question: Some people have a wet dream whilst fasting during the month of Ramadhaan. [In this dream] they [see themselves] do evil and ugly acts. So does [any of] this affect their fast?
Response: If the situation is as described, in that it was a dream, then this does not affect the fast and nor does it reduce it’s reward. However, it is legislated that when he wakes up, he should lightly spit on his left side three times and seek refuge with Allaah from Shaytaan and from the evil he saw [in the dream] three times. [He should] then turn over onto his other side and not inform anyone about it, and [in shaa.-Allaah] this [dream] will not affect him. This is what the Prophet ﷺ commanded whoever saw a dream which he disliked.
And with Allaah lies all success, and may Allaah send prayers and salutations upon our Prophet Muhammad ﷺ and his family and his companions.