Doubt in Salah

It frequently happens during Namaz (Salah) that I forget the correct number of Rak’at I have performed. For example, I get confused during the Salah whether I have performed two Rak’ats or three Rak’ats. Normally in such a situation I repeat my Prayer all over again. Is this what we are supposed to do or is here any other solution to this problem? Please enlighten me in this respect.

You need not repeat the prayer every time you face such a situation. If a person has experienced this confusion for the first time, he or she is required to repeat the Salah. However, if this confusion occurs frequently, as in your case, you are not required to repeat the prayer. Instead, whenever you are confused during your Prayer, you should guess and should act according to the number which appears to you more probable. For example, if you are confused in the Zuhr Prayer whether you have performed two Rak’ats, or three Rak’ats, and after reflection it seems to you more probable that you have performed three Rak’ats, you should act accordingly and after adding one more Rak’at, your four Rak’at will be deemed to have been complete.
But even after reflection, you cannot recollect the actual number of Rak’ats, both possibilities are equal and you cannot prefer one of them over the other, then you should act according to the lesser number. For example, if you caanot reflect whether you have performed two Rak’ats or three Rak’ats, you should presume that you have prayed only two Rak’ats and should add two more Rak’ars to complete your Zuhr prayer.
However, in this case (i.e. when acting according to the lesser number) one should sit for tashahhud after each Rak’at which could possibly be his last Rak’at. Therefore, in the above example, (when one is confused about two or three Rak’at, and takes it to be his second rak’at) he should sit after his next Rak’at and should recite tashahhud, because there is a possibility that it is his fourth and last Rak’at. Then after reciting tashahhud, he should stand up and should complete the four Rak’at according to his presumption, and should perform a sajdah of sahw in the last.
Take another example : Suppose, you are saying the Prayer and get confused whether it is your first Rak’at or the second one. Both possibilities are equal. Now you should take it as your first Rak’at. Normally it means that you should not sit for tashahhud after Sajdah but since there is a possibility that it is your second Rak’at i.e. the last Rak’at in the fair prayer, you should sit after sajdah and after reciting tashahhud should you stand up again and perform another Rak’at with a sajdah of sahw at its end.
In this manner, you can resolve the problem without repeating the prayer.

Fatawa by Mufti Muhammad Taqi Usmani.