Sayyiduna Abu Hurayrah (may Allah be pleased with him) narrates that the Messenger of Allah (peace and blessings be upon him) led us in the Asr prayer and gave the salam after two rak'ahs. Dhul-Yadayn stood up and said: Has the prayer been shortened, or have you forgotten? The Messenger of Allah (peace and blessings be upon him) said: "Neither of these happened." He said: O Messenger of Allah (peace and blessings be upon him), something did happen. The Messenger of Allah (peace and blessings be upon him) turned to the people and said: "Is Dhul-Yadayn telling the truth?" The people said: Yes, O Messenger of Allah. So the Messenger of Allah (peace and blessings be upon him) completed the rest of the prayer, then, after giving the salam, performed two prostrations while sitting. These are the words of the narration of Qutaybah (may Allah have mercy on him).
Imam al-Shafi'i (may Allah have mercy on him) did not mention his words "Neither of these happened," and said: Then he performed two prostrations while sitting, after the salam.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3816
Sayyiduna Imran bin Husayn (may Allah be pleased with him) said that the Prophet (peace and blessings be upon him) gave the salam after three rak'ahs of the Asr prayer, and then went into his house. Then Sayyiduna al-Khirbaq (may Allah be pleased with him), a man with long hands, stood up and called out: O Messenger of Allah! Has the prayer been shortened? The Messenger of Allah (peace and blessings be upon him) came out angry, dragging his cloak, and asked the people. When they informed him (peace and blessings be upon him), he (peace and blessings be upon him) prayed the rak'ah that had been left out. Then he gave the salam, performed two prostrations, and gave the salam again.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3817
Alqamah (may Allah have mercy on him) narrates that Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) led the prayer. Ibrahim al-Nakha'i (may Allah have mercy on him) said: I do not know whether he added something to the prayer or left something out. When he gave the salam, it was said: O Messenger of Allah! Has some new ruling come regarding the prayer? He (peace and blessings be upon him) said: "What is that?" They said: You prayed in such-and-such a way. The Messenger of Allah (peace and blessings be upon him) folded his legs, faced the qiblah and performed two prostrations, then gave the salam. Then, when he turned towards us, he said: "If some new ruling had come regarding the prayer, I would certainly have informed you. But I am a human being like you; I forget just as you forget. So when I forget, remind me. And when any of you is in doubt about his prayer, let him think carefully about what is certain, then complete his prayer on that basis, then give the salam, and then perform the two prostrations of forgetfulness."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3818
Through another chain, Jarir (may Allah have mercy on him) narrates this hadith, and it is like the previous one, except that in it is: He (peace and blessings be upon him) prayed and added something to the prayer or left something out. When he gave the salam, he turned to the people. He did not narrate the words "and he faced the qiblah," and he said at its end: When he has given the salam, he performs the two prostrations of forgetfulness.
It has also been narrated from Sayyiduna Ibn Mas'ud (may Allah be pleased with him) contrary to this regarding the salam, but its authenticity is questionable.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3819
Abu Ubaydah bin Abdullah (may Allah have mercy on him) narrates from his father (Sayyiduna Abdullah bin Mas'ud, may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When you are praying and you are in doubt whether you have prayed three rak'ahs or four, and your stronger assumption is four, then sit for the tashahhud, then perform two prostrations while sitting before giving the salam, then recite the tashahhud again in the same way and give the salam."
Abu Dawud said: Abd al-Wahid narrated it likewise from Khusayf but did not attribute it to the Prophet (peace and blessings be upon him), and Sufyan, Sharik and Isra'il also agreed with Abd al-Wahid. They differed over the wording of the text of the hadith, and they did not narrate it with a chain reaching the Prophet (peace and blessings be upon him).
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3820