Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "When someone has a doubt in his prayer as to whether he has prayed three rak'ahs or four, let him discard the doubt, act upon what he is certain of, and perform two prostrations while sitting before giving the salam. If he has prayed five, the two prostrations will make it even, and if he had prayed the full four, then these (two prostrations) will be a humiliation for Satan."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3800
It is narrated from Ata bin Yasar (may Allah have mercy on him) that the Messenger of Allah (peace and blessings be upon him) said: "When one of you has a doubt about the prayer and does not know how many rak'ahs he has prayed, three or four, let him pray one rak'ah and perform two prostrations while sitting before giving the salam. If the rak'ah he prayed was the fifth, it will be made even by these two prostrations, and if the rak'ah he prayed was the fourth, then these two prostrations will be a cause of humiliation and disgrace for Satan."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3801
Likewise, this same hadith is reported from Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) through another chain.
The narration of Bahr bin Nasr seems to be more correct, though a group (of narrators) narrated the hadith as connected from Zayd bin Aslam, along with Sulayman bin Bilal and Hisham bin Sa'd.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3802
Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "When one of you does not know whether he has prayed three rak'ahs or four, he should complete the prayer and pray one more rak'ah. Then after that he should perform the two prostrations of forgetfulness while sitting. If his rak'ahs have become five, his prayer will become even because of these prostrations, and if his rak'ahs are four, then these two prostrations will be a cause of humiliation and disgrace for Satan."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3803
Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) said: I was sitting with Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) when he said: O Ibn Abbas! Have you heard anything from the Prophet (peace and blessings be upon him) concerning a man who forgets in his prayer and does not know whether he has added something to the prayer or left something out: what did he command regarding it? I said: O Commander of the Believers! Have you not heard anything about this from the Messenger of Allah (peace and blessings be upon him) yourself? He said: No! By Allah, I have not heard anything from him (peace and blessings be upon him) about it, nor did I ask him (peace and blessings be upon him) about it. Suddenly Sayyiduna Abdur Rahman bin Awf (may Allah be pleased with him) arrived and said: What matter are you engaged in? So Sayyiduna Umar (may Allah be pleased with him) told him: I asked this young man about such-and-such a matter, but I did not find any knowledge of it with him. Sayyiduna Abdur Rahman bin Awf (may Allah be pleased with him) said: But I have knowledge of it; I heard it from the Messenger of Allah (peace and blessings be upon him). Sayyiduna Umar (may Allah be pleased with him) said: You are, in our view, a just and approved person, so what did you hear from the Prophet (peace and blessings be upon him)? Sayyiduna Abdur Rahman (may Allah be pleased with him) said: I heard the Prophet (peace and blessings be upon him) say: "When one of you has a doubt in his prayer, if he doubts between one and two rak'ahs, let him count it as one; when he doubts between two and three, let him consider them two; and if he doubts between three and four (rak'ahs), let him make them three, so that the doubt is on the side of excess. Let him perform two prostrations before the salam and then give the salam."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3804
Sayyiduna Ibn Abbas (may Allah be pleased with them both) said: We were with Sayyiduna Umar (may Allah be pleased with him), discussing (the case of) someone who forgets in his prayer and does not even remember how many (rak'ahs) he has prayed. Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) said: I said: I have not heard anything about this from the Messenger of Allah (peace and blessings be upon him). Sayyiduna Ibn Abbas (may Allah be pleased with them both) said: While we were sitting like this, Abdur Rahman bin Awf (may Allah be pleased with him) suddenly arrived and said: What matter are you (troubled) about? We said: A man forgets in his prayer and does not know how many rak'ahs he has prayed. Abdur Rahman bin Awf (may Allah be pleased with him) said: I heard the Messenger of Allah (peace and blessings be upon him) say: "When a man forgets in his prayer and does not know whether he has prayed two, three or four rak'ahs, let him place the forgetfulness on the side of excess and perform two prostrations."
Muhammad bin Ishaq said: I met Husayn bin Abdullah and discussed this hadith with him. He said to me: Did he (Makhul) narrate it with a connected chain? I said: No. He said: But Makhul narrated it to me from Kurayb, from Ibn Abbas, from Abdur Rahman bin Awf, from the Prophet (peace and blessings be upon him), in the same way as this hadith.
Al-Muharibi narrated it from Muhammad bin Ishaq with the meaning of Ibn Ulayyah's narration. So the connection of the hadith rests on Husayn bin Abdullah, and he is da'if (weak), except that it has a supporting narration from the hadith of Makhul.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3805
It is narrated from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) that we were discussing some matter of the prayer with Sayyiduna Umar (may Allah be pleased with him) when Sayyiduna Abdur Rahman bin Awf (may Allah be pleased with him) came to us and said: "Shall I not narrate to you a hadith that I heard from the Messenger of Allah (peace and blessings be upon him)?" We said: Certainly! Please do. He said: I bear witness that I certainly heard this hadith from the Messenger of Allah (peace and blessings be upon him): "When one of you has a doubt about falling short in his prayer, let him pray in such a way that his doubt becomes about excess."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3807
It is narrated from Sayyiduna Anas (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "When one of you has a doubt about his prayer and does not know whether he has prayed two or three, let him discard the doubt and act upon certainty."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3808
Hadith Gradingمحدثین:صحيح لغيره
Hadith Takhrij«صحيح لغيره۔ وقد تقدم الكلام عليه في رقم 3804»
Sayyiduna Abdullah bin Umar (may Allah be pleased with them both) said that the Messenger of Allah (peace and blessings be upon him) said: "When one of you is praying and does not remember how many rak'ahs he has prayed, three or four, let him pray one rak'ah, performing its bowing and prostrations well, and then (at the end) perform two prostrations."
Its narrators are thiqat (trustworthy), and Malik bin Anas reported it as mawquf (a saying of the Companion) in al-Muwatta.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3809
Salim bin Abdullah (may Allah have mercy on him) narrates that Sayyiduna Abdullah bin Umar (may Allah be pleased with them both) used to say: When one of you has a doubt in his prayer, let him reflect on what he thinks he has forgotten of his prayer and pray it, and then at the end perform two prostrations while sitting.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3810
Nafi' (may Allah have mercy on him) said that when Sayyiduna Abdullah bin Umar (may Allah be pleased with them both) was asked about forgetfulness in the prayer, he would say: Let one of you aim for what he thinks he has forgotten of his prayer and pray it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3811
Ata bin Yasar (may Allah have mercy on him) said: I asked Abdullah bin Amr bin al-As (may Allah be pleased with them both) and Ka'b al-Ahbar (may Allah have mercy on him) about a person who has a doubt in his prayer and does not know how many rak'ahs he has prayed, three or four. Both of them said: He should stand up and pray one more rak'ah, and perform two prostrations when he has prayed it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3812