It is also narrated from Sayyiduna Abu Sa'id Khudri (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: When any of you has doubt in prayer and does not know how much he has prayed, then he should base it on certainty (and perform an additional rak‘ah) until he is certain that the prayer is complete. Then, before the salam, he should perform two prostrations. If his (extra performed) prayer is odd-numbered, it will become even due to these two prostrations, and if his prayer is already even (i.e., complete), then these prostrations will humiliate Satan.
Hadith Referenceالفتح الربانی / أبواب الأذ كار الواردة عقب الصلاة / 1981
Hadith Gradingمحدثین:صحیح
Hadith Takhrij«أخرجه مسلم: 571 ، (انظر مسند أحمد ترقيم الرسالة: 11689 ترقیم بيت الأفكار الدولية: 11712»
Brief Explanation
Benefits: … Its meaning is that if a person performs five units (rak‘ahs) in a four-unit (rak‘ah) prayer, then four units will be accepted as obligatory (fard), and the remaining one unit, together with the two prostrations (sajdahs) of forgetfulness (sahw), will be considered as equivalent to two supererogatory (nafl) units. And if he had completed the prayer correctly, then due to the prostrations of forgetfulness, Satan will be humiliated, for he had tried to invalidate the prayer and to confuse the worshipper, but the worshipper, through the additional two prostrations, humiliated him even further.