Guide
How to Stop Sexual Thoughts in Islam
The short answer
A passing sexual thought isn’t held against you. The Prophet said Allah forgave “the evil promptings which arise within their hearts as long as they did not speak about them or did not act upon them.”1 Arguing with a thought or shoving it away tends to keep it around,2 so seek refuge in Allah, lower your gaze, and get up and move.
Self-hatred isn’t piety, and a whisper isn’t a deed. Tie your camel with a plan, and trust Allah with the rest.
Ibrahim’s prayer in the Qur’an closes by naming the one who comes to Allah “with a sound heart” (26:89).3 This page treats that as daily practice. Each time a whisper pulls at you, turn back to Allah, and keep turning back, without despair, as often as it takes.
Are sexual thoughts a sin in Islam?
According to a hadith in both Sahih al-Bukhari and Sahih Muslim, a thought that passes through isn’t counted against you. Speech and action are what count.
In Sahih Muslim, the chapter heading over that hadith speaks of thoughts that pass “so long as they do not become established.”4 A second hadith goes further. When a person intends a bad deed and doesn’t do it, Allah writes “a full good deed” for him. In one version, the reason given is that “he desisted from doing it for My sake.”5 So in this hadith, an urge you let pass for Allah’s sake is written down as good.
Psychology adds that the arriving thought is ordinary. In interviews with students across 13 countries, 94% had had an unwanted thought within three months.6 A thought grows into a craving when the mind starts embellishing it with pictures of relief,7 and that embellishing is where your effort belongs.
Scholars and schools differ on the details, so bring questions about where the line falls to an imam you trust.
What is waswas, and how do you stop it?
Waswas means whispers, or bad thoughts.8 The Qur’an’s answer is to seek refuge in Allah and remember Him, then get on with your day.
The last surah of the Qur’an gives you the words: “I seek refuge in the Lord of mankind … From the evil of the retreating whisperer” (114:1, 4).9 The whisperer retreats. In Ibn Kathir’s commentary, Ibn Abbas explains that it whispers when a person is “absentminded and heedless,” and “when he remembers Allah he withdraws.”10
Another verse joins remembrance to clear sight: “when an impulse touches them from Satan, they remember [Him] and at once they have insight” (7:201).11 Remembering comes first in that verse, and seeing clearly follows. The steps below keep that order.
- Notice the thought. Don’t panic. You didn’t choose it.
- Seek refuge. A’udhu billahi min ash-shaytan ir-rajim: “I seek refuge in Allah from Satan the outcast,” words drawn from 16:98.12
- Don’t argue, and don’t push. A thought you shove away has a way of coming back.13
- Move. Stand up, make wudu, step outside, or start a task that fills your mind.
How does lowering the gaze help?
It cuts thoughts off at the source. Cues set off the first thought, and what you look at is a cue you control.14
The Qur’an tells believing men to “lower their gaze and be modest” (24:30, Pickthall).15 The hadith make it practical. Jarir asked the Prophet about the sudden glance. “He commanded me that I should turn away my eyes,” Jarir reported.16 Another hadith, graded hasan (good), tells Ali that “you are not to blame for the first” look, but “you have no right to the second.”17
The first look, like the first thought, simply happens. The second is a choice.
Today, the gaze includes the screen in your hand. If porn is in the picture, lower it in practical ways:
- After isha, the phone goes to another room for the night.
- Accounts that feed you sexual images get muted or unfollowed.
Cutting cues gets fuller treatment in how to stop thinking about sex all the time.
Isn’t feeling ashamed part of faith?
Haya, a sense of modesty and self-respect, is part of faith. The self-hatred that follows a slip is something else, and it keeps the loop turning.
The Prophet said haya “is a part of faith.” Sunnah.com’s translators note that the word covers “self respect, modesty, bashfulness, and scruple.”18
The shame this page warns against says I am worthless. Guilt says I did wrong. Research links the first to hiding and escape, and the second to setting things right.19 Among 177 people in treatment for compulsive porn use, shame went hand in hand with more of the behavior, and guilt with wanting to change.20
So after a slip, don’t sink into despair. The Qur’an says, “do not despair of the mercy of Allāh. Indeed, Allāh forgives all sins” (39:53).21 Make tawbah, and come back the same day.
How can dhikr and prayer help?
Daily dhikr builds steadiness before an urge comes. One short line in the moment turns you toward Allah and away from the pull.
The Qur’an says, “by the remembrance of Allāh hearts are assured” (13:28).22 Try this rhythm:
- Every day: five to ten minutes of quiet dhikr after one of the daily prayers, at the same time each day. Then recite or read a few ayat with attention, and take one phrase into your day.
- In the moment: one breath, and one line. A’udhu billahi, or With a sound heart.
Then get up and do what your plan says.
What does “tie your camel” mean for urges?
Do your part, then leave the outcome to Allah. That’s tawakkul, trust in Allah.
A man asked the Prophet whether to leave his camel untied and trust in Allah. The answer, in its familiar wording: “Tie your camel, and trust in Allah.”23
- Tie the camel. Put the plan in place before the hard hour. Know what you’ll do when a whisper won’t leave, and whose number you’ll call.
- Trust in Allah. Once the camel is tied, stop replaying what might go wrong tonight. The outcome rests with Him.
For me, surrender meant handing God the burden of the struggle, and my fear and shame with it.
Can fasting help with sexual thoughts?
The Prophet advised young men who couldn’t yet marry to fast. Take it up as discipline and devotion, within what your health allows.
The hadith says those who cannot marry “should devote themselves to fasting for it is a means of controlling sexual desire.”24 Another calls fasting “a shield,” and in it Allah says the fasting person “has left his food, drink and desires for My sake.”25
All day, you feel a pull and don’t act on it, for Allah’s sake. It’s the same skill as riding out an urge, practiced in daylight.
Nothing in this plan works by weakening your body. If you have a health condition, talk to your doctor before you fast. The Qur’an itself makes room for those who are ill (2:184).26
Who can I talk to?
One person who keeps a confidence is enough to start. For many men that’s an imam. For others it’s an older friend in the faith, or a counselor.
Confiding works best when you come away with support and a new way of seeing things.27 In a study of 104 online journals by men giving up porn, help from other people was part of what made change possible.28 Look for someone who listens before advising and asks What’s next? instead of lecturing.
If you worry about speaking of your sins at all, take that question to your imam, in private. That conversation can be your first step.
What if the whispers frighten me?
If a whisper fills you with dread instead of desire, and you find yourself redoing wudu or prayers, or asking whether you’ve sinned, that can be a form of OCD.29 It’s treatable.
Some companions once told the Prophet they found thoughts in their minds too grave to speak of. He asked whether they really felt that, then said, “That is the faith manifest.”30
But if you need that comfort again and again, the need itself may be part of the problem. The International OCD Foundation (IOCDF) calls this pattern scrupulosity: OCD with religious or moral fears. Its signs include repeated washing rituals, excessive praying, needing a prayer to feel perfect, and asking religious leaders for reassurance over and over. It appears across faiths.31
The main treatment is ERP, short for exposure and response prevention, a type of cognitive behavioral therapy. It can include advice from leaders of your faith.32 When you look for an OCD-trained therapist, ask how they’d make room for your faith in treatment, a question the IOCDF itself suggests.33 Don’t diagnose yourself, because distress alone can’t settle it.34
If this is you, the refuge steps above can turn into one more ritual when you use them to force a thought out.35 Ask your therapist how to use them during treatment.
Try this now
Make a refuge card, then rehearse it. It takes about five minutes.
- Write the words. On a card, write A’udhu billahi min ash-shaytan ir-rajim. Under it, write “the retreating whisperer” (114:4), as a reminder that the whisper withdraws.
- Choose your move. Pick one action that takes you away from the screen. Wudu works well, because it gets you on your feet and turns you toward prayer.
- Rehearse it now. Say the words. Then, if you can, stand and make wudu slowly, paying attention to the water and each step. If you can’t right now, walk through it in your mind.
When a real whisper comes, you’ll be repeating something you’ve already practiced. For a strong urge, add the timer from urge surfing.
What steadiness looks like
You stand for fajr, and your mind is on the prayer. On the train, a glance lands where it shouldn’t. You turn your eyes, and the second look never happens. A whisper comes during a meeting, you say a’udhu billahi under your breath, and it withdraws.
On a day you fall short, you make tawbah before maghrib and carry on. Your drive is still part of you, and you decide where it goes. Praying with a clear conscience is better than any relief the loop ever gave.
When to get more help
A doctor or therapist can work alongside any guidance from your imam. Book an appointment if:
- hours of most days go to the thoughts or the behavior
- it carries on despite harm to your family, work, money, or health
- you’ve made real efforts to cut back, and they haven’t held
- whispers leave you redoing wudu or prayers (see above)
- your mood stays low, or anxiety has taken hold
In one randomized trial, 137 men with compulsive sexual behavior who had seven weeks of group CBT did better than men left waiting, with gains still there at six months.36 ABCT in the US and BABCP in the UK both run searchable directories of CBT therapists.37
If shame ever turns into thoughts of harming yourself, reach out now. In the US, call or text 988. In Canada, call or text 9-8-8. In the UK and Ireland, call Samaritans on 116 123. In Australia, call Lifeline on 13 11 14. Elsewhere, findahelpline.com lists free services near you.38
Questions men ask
Will getting married stop these thoughts?
Marriage is a blessing, and the hadith above recommends it for those who can. It doesn’t treat a habit, though. Reaching for relief when you’re stressed or alone can follow a man into marriage, so start the plan now.
What if I slip after making tawbah?
Make tawbah again, the same day. Then look at what set the slip off, and change one thing in your plan. The verse still holds: “do not despair of the mercy of Allāh.”
Is Sound Mind an Islamic book?
Sound Mind by Adam Hale draws on the Qur’an and hadith alongside other traditions, and it’s written for men of every faith and of none. It doesn’t preach or issue rulings. Chapter 1 is free to read online.
Sources
Sahih Muslim 127a, from Abu Huraira, as translated on Sunnah.com: “Verily Allah forgave my people the evil promptings which arise within their hearts as long as they did not speak about them or did not act upon them.” The chapter heading reads, “Allah allows a person’s thoughts and whatever occurs in his heart so long as they do not become established.” The same hadith is in Sahih al-Bukhari 5269. Both are in the two Sahih (“authentic”) collections, and Sunnah.com shows no separate grade for them. Muslim 127a · Bukhari 5269↩︎
Wegner DM, Schneider DJ, Carter SR, White TL. “Paradoxical effects of thought suppression.” Journal of Personality and Social Psychology 1987;53(1):5–13. Across later controlled studies, the rebound is real but small to moderate: Abramowitz JS, Tolin DF, Street GP. Clinical Psychology Review 2001;21(5):683–703. PMID 3612492 · PMID 11434226↩︎
The Qur’an 26:89, Saheeh International translation. The verse closes the prayer of Abraham (Ibrahim), which runs from 26:83 to 26:89. Quran.com API · quran.com/26/89↩︎
Sahih Muslim 127a, from Abu Huraira, as translated on Sunnah.com: “Verily Allah forgave my people the evil promptings which arise within their hearts as long as they did not speak about them or did not act upon them.” The chapter heading reads, “Allah allows a person’s thoughts and whatever occurs in his heart so long as they do not become established.” The same hadith is in Sahih al-Bukhari 5269. Both are in the two Sahih (“authentic”) collections, and Sunnah.com shows no separate grade for them. Muslim 127a · Bukhari 5269↩︎
Sahih al-Bukhari 6491 (a hadith qudsi, from Ibn Abbas): “if somebody intended to do a bad deed and he does not do it, then Allah will write a full good deed (in his account) with Him.” Sahih Muslim 129 (from Abu Huraira) gives the reason: “for he desisted from doing it for My sake.” Translations from Sunnah.com. Bukhari 6491 · Muslim 129 · Muslim 131a↩︎
Radomsky AS et al. Journal of Obsessive-Compulsive and Related Disorders 2014;3(3):269–279. Interviews with 777 university students at 15 sites in 13 countries; 93.6% reported at least one unwanted intrusive thought in the previous three months. doi:10.1016/j.jocrd.2013.09.002↩︎
Kavanagh DJ, Andrade J, May J. “Imaginary relish and exquisite torture: the elaborated intrusion theory of desire.” Psychological Review 2005;112(2):446–467. A theory paper: cues set off intrusive thoughts, and building on them with mental images feeds craving. PMID 15783293↩︎
The Qur’an 114:1–6, Saheeh International translation. Sunnah.com’s chapter heading for Sahih Muslim 132 glosses waswasah as “Whispers, Bad Thoughts.” Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30 · Muslim 132a↩︎
The Qur’an 114:1–6, Saheeh International translation. Sunnah.com’s chapter heading for Sahih Muslim 132 glosses waswasah as “Whispers, Bad Thoughts.” Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30 · Muslim 132a↩︎
Tafsir Ibn Kathir (abridged English translation), on 114:4, reporting Ibn Abbas through Sa’id bin Jubayr: “So when he becomes absentminded and heedless he whispers. Then, when he remembers Allah he withdraws.” Quran.com · API↩︎
The Qur’an 7:201, Saheeh International translation. The verse before it (7:200) reads, “if an evil suggestion comes to you from Satan, then seek refuge in Allāh.” Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30↩︎
The Qur’an 16:98, Pickthall translation (1930): “seek refuge in Allah from Satan the outcast.” Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30↩︎
Wegner DM, Schneider DJ, Carter SR, White TL. “Paradoxical effects of thought suppression.” Journal of Personality and Social Psychology 1987;53(1):5–13. Across later controlled studies, the rebound is real but small to moderate: Abramowitz JS, Tolin DF, Street GP. Clinical Psychology Review 2001;21(5):683–703. PMID 3612492 · PMID 11434226↩︎
Kavanagh DJ, Andrade J, May J. “Imaginary relish and exquisite torture: the elaborated intrusion theory of desire.” Psychological Review 2005;112(2):446–467. A theory paper: cues set off intrusive thoughts, and building on them with mental images feeds craving. PMID 15783293↩︎
The Qur’an 24:30, Pickthall translation (1930). Saheeh International renders the phrase “reduce [some] of their vision.” Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30↩︎
Sahih Muslim 2159a, from Jarir bin Abdullah, as translated on Sunnah.com: “I asked Allah’s Messenger (ﷺ) about the sudden glance (that is cast) on the face (of a non-Mahram). He commanded me that I should turn away my eyes.” Muslim 2159a · Abu Dawud 2149 · Tirmidhi 2777↩︎
Sunan Abi Dawud 2149, from Buraydah, graded hasan by al-Albani on Sunnah.com: “Do not give a second look, Ali, (because) while you are not to blame for the first, you have no right to the second.” A similar report, Jami’ at-Tirmidhi 2777, is graded da’if (weak) by Darussalam. Muslim 2159a · Abu Dawud 2149 · Tirmidhi 2777↩︎
Sahih al-Bukhari 9, from Abu Huraira: “Faith (Belief) consists of more than sixty branches (i.e. parts). And Haya … is a part of faith.” The note on the word is the Sunnah.com translator’s. Bukhari 9↩︎
Tangney JP, Stuewig J, Mashek DJ. “Moral emotions and moral behavior.” Annual Review of Psychology 2007;58:345–372. A review. PMID 16953797↩︎
Gilliland R, South M, Carpenter BN, Hardy SA. “The roles of shame and guilt in hypersexual behavior.” Sexual Addiction & Compulsivity 2011;18(1):12–29. An online survey of 177 people seeking treatment for compulsive porn use. A link, not proof. doi:10.1080/10720162.2011.551182↩︎
The Qur’an 39:53, Saheeh International translation. Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30↩︎
The Qur’an 13:28, Saheeh International translation. Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30↩︎
Sahih Ibn Hibban 731, translated by Abu Amina Elias as “Tie her and trust in Allah,” and graded hasan by al-Arna’ut; this page uses the familiar English wording. A similar report is Jami’ at-Tirmidhi 2517 (“Tie it and rely (upon Allah)”), graded hasan by Darussalam. Daily Hadith Online · Sunnah.com↩︎
Sahih Muslim 1400a, from Abdullah bin Mas’ud, as translated on Sunnah.com. The same hadith is in Sahih al-Bukhari 5066, where Sunnah.com’s translation reads that fasting “diminishes his sexual power.” Muslim 1400a · Bukhari 5066 · Bukhari 1894↩︎
Sahih al-Bukhari 1894, from Abu Huraira, as translated on Sunnah.com: “Fasting is a shield (or a screen or a shelter).” Muslim 1400a · Bukhari 5066 · Bukhari 1894↩︎
The Qur’an 2:184, Saheeh International translation: “So whoever among you is ill or on a journey [during them] - then an equal number of other days [are to be made up].” Quran.com API · 7:200–201 · 13:28 · 39:53 · 114:1–6 · 2:184 · 16:98 · 24:30↩︎
Nguyen CQ, Slepian ML. “Revealing secrets.” Current Opinion in Psychology 2022;47:101425. A review. PMID 36029700↩︎
Fernandez DP, Kuss DJ, Griffiths MD. Archives of Sexual Behavior 2021;50(2):711–728. 104 journals by men on an online porn-abstinence forum. A qualitative study of a self-selected group, so it describes experience rather than proving cause. PMID 33403533↩︎
International OCD Foundation. “Scrupulosity” fact sheet, by C. Alec Pollard, 2010. It names “Repeated cleansing and purifying rituals,” “Excessive praying (sometimes with an emphasis on the prayer needing to be perfect),” “Repeating passages from sacred scriptures in one’s head,” and “Repeatedly seeking reassurance from religious leaders and loved ones” among the compulsions, and says scrupulosity “can affect individuals from a variety of different faith traditions.” PDF↩︎
Sahih Muslim 132a, from Abu Huraira, as translated on Sunnah.com: “Verily we perceive in our minds that which every one of us considers it too grave to express. He (the Holy Prophet) said: Do you really perceive it? They said: Yes. Upon this he remarked: That is the faith manifest.” Muslim 132a↩︎
International OCD Foundation. “Scrupulosity” fact sheet, by C. Alec Pollard, 2010. It names “Repeated cleansing and purifying rituals,” “Excessive praying (sometimes with an emphasis on the prayer needing to be perfect),” “Repeating passages from sacred scriptures in one’s head,” and “Repeatedly seeking reassurance from religious leaders and loved ones” among the compulsions, and says scrupulosity “can affect individuals from a variety of different faith traditions.” PDF↩︎
American Psychiatric Association practice guideline (Koran LM et al. American Journal of Psychiatry 2007;164(7 Suppl):5–53) and NICE guideline CG31 name CBT with ERP as a first-line treatment for OCD. The IOCDF fact sheet calls it “the primary psychological treatment for scrupulosity” and says treatment “may also include consultation from leaders of the patient’s faith tradition.” PMID 17849776 · CG31 · PDF↩︎
International OCD Foundation, “How to Find the Right Therapist.” One suggested question: “How would you include aspects of my cultural identity, such as age, faith, gender, race, or sexual orientation, in my care?” How to Find the Right Therapist↩︎
Vella-Zarb RA, Cohen JN, McCabe RE, Rowa K. Cognitive and Behavioral Practice 2017;24(3):342–352. A clinical paper: distress alone doesn’t reliably separate OCD from other sexual thoughts. doi:10.1016/j.cbpra.2016.06.007↩︎
International OCD Foundation. “Scrupulosity” fact sheet, by C. Alec Pollard, 2010. It names “Repeated cleansing and purifying rituals,” “Excessive praying (sometimes with an emphasis on the prayer needing to be perfect),” “Repeating passages from sacred scriptures in one’s head,” and “Repeatedly seeking reassurance from religious leaders and loved ones” among the compulsions, and says scrupulosity “can affect individuals from a variety of different faith traditions.” PDF↩︎
Hallberg J et al. Journal of Sexual Medicine 2019;16(5):733–745. 137 men were randomly assigned to seven weeks of group CBT or a waiting list. One trial: promising, not proven. PMID 30956109 · PMID 32900671↩︎
Therapist directories, checked October 16, 2026: ABCT’s Find a CBT Therapist (US) and BABCP’s Find a therapist (UK). Find a CBT Therapist · Find a therapist · babcp.com · Referral Directory · AASECT Certified Sex Therapist · Top FAQs · Find a Therapist · Relate↩︎
Crisis lines, checked on each official site October 16, 2026: 988 Suicide & Crisis Lifeline (US), 9-8-8 (Canada), Samaritans (UK and Ireland), Lifeline (Australia), and Find A Helpline. 988 Suicide & Crisis Lifeline · 9-8-8 Suicide Crisis Helpline · about 9-8-8 · Samaritans · Samaritans Ireland · Lifeline Australia · Find A Helpline↩︎
This guide is education, not medical advice. Read our medical disclaimer and editorial standards.