In fact, when speaking about masturbation, let’s admit and make it clear that it is generally forbidden. This prohibition is based on some proofs from the Shari`ah. For example, Allah says, “Those who guard their sexual organs except with their spouses or those whom their right hands possess, for (with regard to them) they are without blame. But those who crave something beyond that are transgressors.” (Al-Mu’mun: 5-7)
Having stated the above, let’s now focus on how a Muslim could protect himself against committing such a sin. The following tips are useful in shaa’ Allah:
1. encircle yourself with righteous and practicing Muslim brothers/sisters
2. keep yourself busy in worship and spiritual acts.
3. interact with activities of the society in such a way that it keeps you away from thinking about sex.
4. avoid gatherings and places that bring men and women physically close to each other.
5. trying to admire natural things such as flowers and beautiful scenery, which do not stimulate one sexually, instead of admiring the opposite gender.
6. try to get married as soon as possible to a good Muslim spouse.
7. make du`aa’ to Allah to protect you against vices
Finally, we would say that some scholars allowed masturbations in exceptional situations such as when an unmarried young person fears that without masturbation he/she will commit zina, and, as long as the masturbation here is, rather than fulfilling a sexual desire, just to release the sexual tension resulting from stimulation. Of course, masturbation requires ghusl since the emission of semen is one of the causes that necessitates ritual bathing.