Blog
masturbationislamic rulingsporn blockerislam

Is Masturbation Haram? What the Four Madhhabs Say

Is masturbation haram in Islam? The sourced positions of the four madhhabs, the narrow Hanbali necessity exception, and a practical Muslim plan to stop.

Is Masturbation Haram? What the Four Madhhabs Say
N

Nafs Team

· 10 min read

Is masturbation haram? According to the majority of scholars, yes. The Shafi’i, Maliki and Hanbali schools state that it is prohibited, and Hanafi scholars also prohibit it unless there is an excuse. The Hanbali school allows a narrow exception for necessity: a person who genuinely fears falling into zina and has no means to marry. None of the four schools treats it as a harmless habit.

Nafs does not issue fatwas. This page summarises what recognised fatwa bodies and scholars have published, with links, so you can read the sources yourself. For your own circumstances, ask a qualified scholar you trust.

A ruling is most useful when it leads to a next step. For many people the habit starts on the phone: a suggestive feed, a search, then a private tab. Close that route with Nafs before the next urge, and keep device-level adult-content filtering and accountability in place for broader protection.

The four madhhabs at a glance

The school-by-school summary below draws on Egypt’s Dar al-Ifta fatwa on whether masturbation is prohibited (2013) and on IslamOnline’s overview of the schools.

SchoolPositionNote
Shafi’iProhibitedImam al-Shafi’i derived the prohibition from Quran 23:5–7 (IslamQA).
MalikiProhibitedImam Malik read the same verse as covering masturbation (IslamOnline).
HanafiProhibited, unless there is an excuseSome Hanafi scholars classed it as disliked (makruh) and discussed relieving overwhelming desire.
HanbaliProhibited, except in necessityPermitted only out of necessity: IslamOnline names a real fear of zina and no means to marry; Dar al-Ifta describes a necessity that would otherwise cause physical or religious harm.

The sources word the Hanafi position in slightly different ways, but they agree on the main point: no school permits masturbation as a habit or as a way to stir up desire.

The Quranic evidence: Surah al-Mu’minun 23:5–7

The verse most often cited describes the successful believers as those who guard their private parts, except with their spouses or those their right hands possess, and then says that whoever seeks beyond that has transgressed (Quran 23:5–7).

Scholars who prohibit masturbation read “whoever seeks beyond that” as covering any sexual release outside a lawful marriage, including by one’s own hand. IslamQA attributes this reading to Imam al-Shafi’i, and IslamOnline attributes it to Imam Malik.

A second verse is also cited. Allah tells those who cannot yet marry to keep themselves chaste until He enriches them from His bounty (Quran 24:33). The instruction is restraint, not another outlet.

The hadith: marry, or fast

The Prophet ﷺ told young people that whoever can marry should marry, because it helps lower the gaze and guard chastity, and that whoever cannot should fast, because fasting restrains desire (Sahih al-Bukhari 5066).

Scholars point out that the Prophet ﷺ named fasting, which is harder, rather than masturbation, which is easier. IslamQA uses that silence as part of its evidence for the prohibition (IslamQA).

The majority view and the Hanafi nuance

Dar al-Ifta states that masturbation is prohibited according to the majority of scholars and is allowed only in cases of necessity. On the Hanafi school, it reports that masturbation is prohibited except with an excuse, and that some Hanafi scholars considered it disliked; it quotes the Hanafi jurist Ibn Nujaym on there being “no harm” when the only aim is to relieve desire (Dar al-Ifta).

SeekersGuidance, answering from the relied-upon positions of the Hanafi and Shafi’i schools, states plainly that masturbation is prohibited and that viewing pornography is prohibited (SeekersGuidance, 2022).

The Hanbali necessity exception: what it is and what it is not

The Hanbali exception is the one people most often ask about, usually as “can I masturbate to avoid zina?” It is narrower than it sounds.

  • The conditions are strict. IslamOnline summarises the Hanbali position as permission only when two conditions are met: a real fear of committing zina, and not having the means to marry (IslamOnline). Dar al-Ifta words it as permissible “when there is a necessity”.
  • It is not permission to arouse yourself. Dar al-Ifta’s separate fatwa says that deliberately stirring up desire through masturbation without necessity is prohibited (Dar al-Ifta).
  • It does not cover pornography. The same fatwa states that watching pornographic films is prohibited. For that question, see is watching porn haram in Islam.
  • It is not a description of most nights. IslamQA warns that many people who claim the exception are not at the point of zina at all (IslamQA). Boredom, a late-night feed or a habit is not the same as necessity.

Because the exception depends on personal circumstances, take it to a qualified scholar while you are calm. Do not decide it in the middle of an urge.

Is it a major sin, and can it be forgiven?

Scholars classify sins in different ways, and this page does not rank it for you. What the sources agree on is that it is prohibited by the majority, that it should not be taken lightly, and that it is not beyond Allah’s forgiveness.

Allah tells those who have wronged themselves not to despair of His mercy, because He forgives all sins (Quran 39:53). In a hadith qudsi, a servant sins, asks forgiveness, falls again and asks again, and each time Allah forgives him because he knows he has a Lord who forgives (Sahih al-Bukhari 7507). That hadith is about returning, not about permission to keep going.

What the ruling means for ghusl, prayer and fasting

  • Ghusl. If sexual fluid is emitted with desire, ghusl is required before you pray. The steps are in what to do after masturbation in Islam and the full ghusl guide.
  • Prayer. Shame does not cancel salah. Make ghusl, then pray as normal.
  • Fasting. Deliberate emission during the day breaks the fast according to the four imams. The make-up and expiation details by school are in does masturbation break your fast.

A practical plan once you know the ruling

The scholars’ advice is consistent: marry if you can, fast if you cannot, stay busy with what benefits you, and stay away from what triggers you. In practical terms:

  1. Repent now, not after “one more time”. Stop, regret it, ask Allah’s forgiveness and intend not to return.
  2. Lower the gaze on the screen. Allah commands believing men and women to lower their gaze and guard their chastity (Quran 24:30–31). On a phone, that means unfollowing suggestive accounts and blocking the app that usually starts the loop.
  3. Fast voluntarily when it is safe for you, for example on Mondays and Thursdays, following the hadith above.
  4. Change the place and the hour. Keep the phone out of bed and out of the bathroom. Charge it in a shared room.
  5. Prepare for the next urge. Lock the screen, stand up, leave the private place, make wudu and do something else for ten minutes. The full version is the 10-minute urge plan.
  6. Involve someone. A trusted friend, spouse or imam. If the behaviour feels compulsive or is harming your life, a licensed counsellor or therapist can help alongside religious support.

Some readers call the porn-masturbation-orgasm cycle “PMO”. If that is your pattern, the practical plan to stop masturbation and quit PMO covers trigger mapping, relapse and support in more depth.

Put a barrier in front of your trigger apps with Nafs.

How Nafs helps you keep away from it

The Quran does not only forbid zina; it tells believers not to come near it (Quran 17:32). Closing the routes that lead to a sin is part of acting on your repentance, and for many people those routes run through the phone. Nafs is one tool for that. It is not a religious requirement, and no app guarantees a result.

  • Block the apps that start the loop (iPhone and Android). In the Fortress tab, choose the feeds, browsers or other apps that begin the pattern. On iPhone, app blocking uses Screen Time and requires iOS 16 or later.
  • Turn on adult-site protection. On Android, Guard can identify and block known adult domains in supported browsers when the Accessibility permission and protection are enabled. On iPhone, Nafs enables Apple’s adult-content filter for Safari and in-app WebKit on iOS 16 or later with the required Screen Time access. Coverage depends on the browser and device; it does not filter every in-app feed, browser or other device.
  • Ride out the urge (iPhone and Android). Tap “I have an urge” on the Today screen or in the Fortress tab. It opens a calm screen that breathes with you, shows the intention you wrote in your own words, and gives you a dua to say.
  • Learn in short lessons (iPhone and Android). Three courses of 14 lessons each, a few minutes a day, with the first lessons of every course free.
  • Earn time back with worship. Quran and dhikr earn back screen time for the ordinary apps you choose to allow. Adult content is never something you unlock.
  • Make turning it off slower (Pro). With Iron Intention, turning off your guard needs a 24-hour cooling-off.
  • Lock apps at prayer time (Android only). Your locked apps pause for 15 minutes at each prayer, until you log it.

A removable blocker can be bypassed. If you keep undoing your own restrictions, ask a trusted person to hold the passcode. Nafs is free to download with optional in-app purchases; see how Nafs works for Muslims quitting porn.

Frequently asked questions

Is masturbation haram for women too?

Yes. The scholars cited here apply the same ruling to men and women; IslamQA states this explicitly (IslamQA). If fluid is emitted with desire, ghusl is required for women as well, as explained in what to do after masturbation.

Is it still haram if I do not watch anything?

Not watching pornography removes one prohibited act, but it does not make masturbation permissible. The positions above concern masturbation itself. Pornography is a separate prohibition.

Is masturbation the same as zina?

No. Zina has its own definition and legal consequences in fiqh, and the scholars cited here do not equate the two. That does not make masturbation permissible; the majority still hold it prohibited.

Does getting married solve it?

Marriage is the lawful outlet the hadith points to, and scholars encourage it for those who can. It is not an automatic cure for a compulsive pattern. Yaqeen Institute’s essay on prophetic solutions to pornography advises that recovery should already be underway before marriage, because a spouse should not have to act as a therapist.

Who should I ask about my own situation?

A qualified scholar you trust, preferably one who follows the school you follow. Describe the situation briefly; you do not need to share explicit details.

Put a barrier between the urge and the next tap.

Use Nafs to block selected trigger apps and redirect the interruption into Quran, dhikr, dua, or salah. Pair it with device-level filtering and accountability for broader adult-content protection.

Set up Nafs for your trigger apps

Nafs supports habit change; it is not treatment, and website coverage varies by platform, browser, permissions, and current app release.