The Prohibitions of Masturbation
Masturbation (for both men and women) is haraam (forbidden) in Islam based on the following evidence:
First from the Qur'aan:
Imam Shafi'i stated that masturbation is forbidden based on the following verses from the Qur'aan (interpretation of the meaning):
"And those who guard their chastity (i.e. private parts, from illegal sexual acts). Except from their wives or (the captives and slaves) that their right hands possess, - for them, they are free from blame. But whoever seeks beyond that, then those are the transgressors." 23.5-7 Here the verses are clear in forbidding all illegal sexual acts (including masturbation) except for the wives or that their right hand possess. And whoever seeks beyond that is the transgressor.
let those who find not the financial means for marriage keep themselves chaste,
until Allah enriches them of His bounty." 24.33. This verse also clearly
orders whoever does not have the financial means to marry to keep himself
chaste and be patient in facing temptations (including masturbation) until
Allah enriches them of His bounty.
Among those whom Allah will not look at on the Day of Resurrection, and to whom He will say, "Enter the Fire along with those who enter," the Prophet (pbuh) counted the following: The active and the passive partners in homosexuality; the one who has sex with animals; the one who is married to a woman and her daughter at the same time; and the one who masturbates regularly, unless they repent and reform.