The scholars have stated that if a person does an act of worship and finishes it, then is uncertain as to whether he has completed it or not, and this doubt does not reach the level of certainty, then no attention should be paid to it and the act of worship is valid and complete, in sha Allaah.
This applies especially in the case of one who experiences a lot of doubts concerning acts of worship. It is not permissible for such a person to pay attention to his doubts, for they are tricks of the shaytaan.
Ibn Qudaamah said in al-Mughni (3/187):
If a person has doubts about his tahaarah (purity) whilst he is doing tawaaf, that tawaaf is not valid, because he had doubts about a condition of worship before he had finished it. The same applies if he has doubts about his tahaarah whilst praying.
But if the doubts come after he has finished the act of worship, then he does not have to do anything, because a doubt about an act of worship after it has been completed does not have any effect on it. End quote.
Al-Zarkashi said in al-Manthoor fi’l-Qawaa’id al-Fiqhiyyah (2/257):
Imam al-Shaafa’i differentiated between doubts during an action and doubts after an action. In the second case he did not say that it must be repeated, because that would cause hardship. If a worshipper were required to remember what he had done in prayer, that would be too difficult for him and no one would be able to do that, so there is some leniency in the matter. End quote.
The Standing Committee was asked the following question:
Should any attention be paid to doubts about the number of rak’ahs, or the number of circuits of tawaaf or saa’i, after the action has been completed? Is that also the case with regard to wudoo’ or not? i.e., should no attention be paid to doubts that come after the act of worship has been completed?
No attention should be paid to doubts that come after completing tawaaf, saa’i and prayer, because it seems that the act of worship is sound. End quote.
Fataawa al-Lajnah al-Daa’imah, 7/143
Shaykh Ibn ‘Uthaymeen was asked about a person who experienced a great deal of doubt concerning his prayer: what is your advice?
No attention should be paid to many doubts, because that will lead to waswaas (whispers from the shaytaan). The shaytaan will not stop at raising doubts concerning that, rather he will make him doubt other things, until he even makes him have doubts concerning Tawheed and the attributes of Allaah, may He be exalted, or he may make him wonder whether his wife is divorced from him or is still his wife. This poses a threat to a man’s sanity and his religious commitment.
Hence the scholars said that no attention should be paid to doubts in three cases:
1 – When it is simply imagination with no basis in reality. This should be ignored completely and no attention paid to it at all.
2 – When there are many doubts and a person has doubts every time he does wudoo’, or every time he prays, or every time he does something. This should also be ignored completely and no attention paid to it at all.
3 – If the doubt comes after completing an act of worship. No attention should be paid to it so long as one is not certain of the matter.
For example: if a person is uncertain, after saying the salaam at the end of the prayer, whether he prayed three or four rak’ahs of a four-rak'ah prayer, he should not pay any attention to this doubt because he has completed the prayer. But if he is certain that he did not pray more than three rak’ahs, he should do the fourth rak’ah if he has just recently completed the prayer, then do the prostration of forgetfulness after saying the tasleem. If some time has passed, then he should do the whole prayer over again. End quote.
Majmoo’ Fataawa Ibn ‘Uthaymeen, 14/ question no. 746
And Allaah knows best.