Praise be to Allah.
Waswasah (compulsive thoughts) is a kind of sickness that stems from the Shaytaan gaining control over a person, or when a person is overpowered by his nafs that is inclined to evil. Hence the remedy for that is to strengthen your faith and weaken the Shaytaan’s leverage over you; to do a lot of acts of worship and turn to Allah, remembering Him (dhikr), glorifying Him (tasbeeh) and seeking His forgiveness; to resort to prayer; and to turn to Allah, may He be exalted, and beseech Him to relieve you of this evil and harm. For He, may He be glorified, is the best to respond, and He is more merciful to His slave than he is to himself. Allah, may He be exalted, says (interpretation of the meaning):
“Is not He (better than your gods) Who responds to the distressed one, when he calls Him, and Who removes the evil, and makes you inheritors of the earth, generations after generations. Is there any ilah (god) with Allah? Little is that you remember!”
“And (remember) Ayoob (Job), when he cried to his Lord: ‘Verily, distress has seized me, and You are the Most Merciful of all those who show mercy.’
So We answered his call, and We removed the distress that was on him”
You will find that many of those who are afflicted with waswasah are neglectful of reciting the adhkaar that are prescribed for morning and evening, when going to sleep, when entering and exiting the house, and when eating and drinking. This gives the Shaytaan more power over them and enables him to instil in them bad and evil thoughts, so as to increase them in distress and grief.
One of the most effective ways of dealing with waswasah is to ignore it and to try hard to pay no attention to it, until it goes away altogether. Ibn Hajar al-Makki (may Allah have mercy on him) was asked about the disease of waswasah; is there any remedy for it?
He replied: There is an effective remedy for it, which is to ignore it altogether, no matter how often these thoughts come to mind. If no attention is paid to them, then they will not take root; rather they will disappear after a short time, as has happened with those who are given divine help. As for the one who pays attention to them and acts accordingly, they will continue to increase until they drive him to insanity, and even worse, as we have seen in the case of many of those who were faced with these compulsive thoughts, and they paid attention to them and to the devils who cause them.
End quote from al-Fataawa al-Fiqhiyyah al-Kubra (1/149).
The one who is faced with the problem of waswasah should understand that he will not be called to account for ideas that cross his mind, no matter how bad they are, whether they come to him whilst he is praying or otherwise, so long as he hates them and wants them to go away. This is indicated by the report narrated by Muslim (132) from Abu Hurayrah, who said: Some of the companions of the Prophet (blessings and peace of Allah be upon him) came and asked him: We find in ourselves something that is too awful for any of us to speak of it. He said: “Do you really find that?” They said: Yes. He said: “That is clear faith.”.
In other words, hating that and being distressed by it is indicative of faith in the heart.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him) was asked:
Whispers and thoughts may cross a person’s mind, especially with regard to Tawheed and faith; will the Muslim be brought to account for that?
He replied: It is proven from the Messenger of Allah (blessings and peace of Allah be upon him), in as-Saheehayn and elsewhere, that he said: “Allah has pardoned my ummah for what crosses their minds, so long as they do not act upon it or speak of it.” Agreed upon. And it is proven that the Sahaabah (may Allah be pleased with them) asked him (blessings and peace of Allah be upon him) about what might cross their minds of these whispers and thoughts, and what is referred to in the question, and he (blessings and peace of Allah be upon him) responded by saying, “That is clear faith.” Narrated by Muslim. And he (blessings and peace of Allah be upon him) said: “People will keep asking questions until it is said: Allah created this creation, but who created Allah? Whoever experiences anything of that nature, let him say: I believe in Allah and His Messengers.” Agreed upon. According to another report, he said: “…let him seek refuge with Allah and stop (such thoughts).” Narrated by Muslim in his Saheeh.
End quote from Tuhfat al-Ikhwaan bi Ajwibah Muhimmah tata‘allaq bi Arkaan al-Islam, question no. 10.
As that is the case, then you must be very cautious and avoid listening to the whispers of the Shaytaan about giving up worship because of what crosses one’s mind of haraam matters whilst praying. Rather the individual should continue with his prayer, no matter what crosses his mind, and he should not interrupt his prayer or repeat it; rather he should strive to ignore these thoughts, and they will go away, by Allah’s leave.
See the answer to question no. 25778.
However, we should point out here that it is essential for her to keep away from anything that may provoke these whispers and evil thoughts in her mind, such as watching movies or looking at indecent images that may settle in people’s minds, and lead to them acting upon them, even if that is after a while.
If she is faced with any problem of that nature, despite her dislike of it, or if she feels that she has desire for intimacy with her husband, then she should fulfil her desire with her husband first, before she prays, if that is possible and there is still enough time for offering an obligatory prayer.
Abu’d-Dardaa’ (may Allah be pleased with him) said: It is part of a person’s understanding of religion to fulfil his needs (or desires) so that he can focus on his prayer wholeheartedly. Narrated by al-Mirwazi in Ta‘zeem Qadr as-Salaah (134), and in a mu‘allaq report in Saheeh al-Bukhaari.
We ask Allah, may He be glorified and exalted, to help and guide us and you.
For more information on ways of attaining proper focus and humility in prayer, please see the essay 33 Ways of Attaining Khushoo‘ (proper focus and humility) In Prayer in the Articles & Books section of our website.
And Allah knows best.