Praise be to Allaah.
These and similar unpleasant dreams come from the Shaytaan. What is prescribed for the Muslim, if he sees a dream that he dislikes, is to spit drily to his left three times and to seek refuge with Allaah from the Shaytaan and from the evil of what he has seen, three times, and he should turn over onto his other side. Then it (his dream) will not harm him. And he should not tell anyone about it, because the Prophet (peace and blessings of Allaah be upon him) said: “The good dream comes from Allaah and the bad dream comes from the Shaytaan. So if any one of you sees a bad dream which frightens him, 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, Bad’ al-Khalq, 3049).
If a woman sees in a dream that someone is having intercourse with her, this is something natural, for women may experience erotic dreams just as men do. An erotic dream (or “wet dream”) is when one imagines doing sexual acts in one’s dream. It was narrated in a hadeeth that Umm Salamah said: “Umm Sulaym came to the Messenger of Allaah (peace and blessings of Allaah be upon him) and said, ‘O Messenger of Allaah, Allaah is not too shy to tell us the truth. Does a woman have to do ghusl if she experiences an erotic dream?’ The Prophet (peace and blessings of Allaah be upon him) said: ‘(Yes), if she sees some wetness.’” (Narrated by al-Bukhaari, al-‘Ilm, 127). Shaykh al-Bassaam said that the word ihtamalat (translated here as “she sees an erotic dream”) refers to whatever a sleeper may see in his dreams, and what it means here is if a woman sees in her dream what men see of images of intercourse and the like. If a woman sees such things in her dream, then if something comes out of her as a result of that dream, she has to do ghusl. But if she simply sees a dream and nothing comes out of her, then she does not have to do ghusl, because the Prophet (peace and blessings of Allaah be upon him) said, “If she sees some wetness.”
And Allaah knows best.
See Tawdeeh al-Ahkaam, 1/297