Allaah is not too shy to tell the truth. What is the ruling on what happens to me – thinking about intercourse, which is followed by ejaculation of semen as the result of desire? This is because of repeatedly thinking, without touching the private part and without moving or speaking. I am afraid that I may have committed a major sin, and I have done this numerous times because thinking is easy and is provocative for me. It is difficult to avoid it in some situations but praise be to Allaah I do not let my gaze wander.
What you are doing, by deliberately thinking about intercourse and enjoying that, which leads to emission of semen, is a haraam action from which you have to repent, as well as regretting what has happened in the past and resolving not to do it again.
The Standing Committee for Issuing Fatwas was asked: Is it permissible for a young single man to think about intercourse, i.e., to imagine that he is having intercourse with his wife although he is not yet married?
It is not permissible for him to do that, because it is a means that may lead to committing immoral actions and falling into evil and immoral ways. End quote from Fataawa al-Lajnah al-Daa’imah, 26/345.
They were also asked: A man’s desire may be provoked and he may think about intercourse a great deal, and emit semen. Does this come under the heading of masturbation? This is one thing. If he thinks about intercourse so that he can ejaculate and feel pleasure, does that also come under the heading of masturbation? We hope that you can explain the Islamic point of view to us concerning this matter. May Allaah reward you with good.
They replied: If a thought crosses a person’s mind and he thinks of intercourse accidentally, then there is no sin on him, in sha Allaah, because it is narrated in a saheeh hadeeth from Abu Hurayrah (may Allaah be pleased with him) that the Prophet (peace and blessings of Allaah be upon him) said: “Allaah has forgiven my ummah for what crosses their minds.” According to another report: “For what crosses their minds, so long as they do not act upon it or speak of it.”
But the one who thinks and ejaculates with pleasure as the result of thinking has to do ghusl, because the rulings on janaabah apply to him in this case. But if he thinks about that deliberately from time to time, that is not permissible, and it does not befit the attitude of the Muslim and is contrary to chivalry and good character. The Muslim should refrain from that and keep himself busy with things that will prevent the provocation of his desire and will benefit him in both spiritual and worldly terms. Deliberately provoking desires in ways that are not acceptable or prescribed in sharee’ah is harmful to one's physical and mental health, and there is the fear that it may lead to bad consequences.
The matter is even worse if he does that when Allaah has given him a wife and when the husband becomes accustomed to this bad habit and allows his mind wander freely, then his relationship with his wife and the tranquility and compassion that Allaah has created between husband and wife will be in danger. End quote.
Fataawa al-Lajnah al-Daa’imah, 22/66
We ask Allaah to help you to give up this evil deed and to bless you with chastity.
And Allaah knows best.