It is narrated from Sayyiduna Imran bin Husayn (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) led them in prayer and he (peace and blessings be upon him) forgot; then he (peace and blessings be upon him) performed the two prostrations of forgetfulness, then recited the tashahhud and gave the salam.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3896
(a) This hadith is also transmitted through another chain, in which it states that the Prophet (peace and blessings be upon him) led them in prayer and forgot; then he (peace and blessings be upon him) performed two prostrations, after which he recited the tashahhud and then gave the salam.
(b) Muhammad states: I was informed via Imran (may Allah be pleased with him) that he mentioned the salam and did not mention the tashahhud; and in the narration of Hushaym the tashahhud is mentioned before the two prostrations.
Ash'ath al-Humrani is alone in narrating this. Shu'bah, Wuhayb, Ibn Ulayyah, al-Thaqafi, Hushaym, Hammad bin Zayd, Yazid bin Zuray' and others narrated it from Khalid al-Hadhdha, and none of them mentioned what Ash'ath mentioned from Muhammad from him; this indicates Ash'ath's error in what he narrated.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3897
Sayyiduna Imran bin Husayn (may Allah be pleased with him) says that the Messenger of Allah (peace and blessings be upon him) led Zuhr or Asr as three rak'ahs. A man who was called Sayyiduna al-Khirbaq (may Allah be pleased with him) said: "O Messenger of Allah, you have prayed only three rak'ahs." He (peace and blessings be upon him) asked: "Is that really so?" The Companions (may Allah be pleased with them) said: "Yes." He (peace and blessings be upon him) stood up and led one rak'ah, then prostrated, then recited the tashahhud, gave the salam and performed the two prostrations of forgetfulness, after which he gave the salam.
This is the correct version with this wording, and Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3898
(a) Salamah bin Alqamah (may Allah have mercy on him) says: I asked Muhammad bin Sirin (may Allah have mercy on him): Is there a tashahhud in the prostrations of forgetfulness? He said: I did not hear it in the hadith of Abu Hurayrah (may Allah be pleased with him), but reciting the tashahhud is preferable to me.
(b) Imam al-Bukhari (may Allah have mercy on him) says: Anas (may Allah be pleased with him) and al-Hasan (may Allah have mercy on him) gave the salam and did not recite the tashahhud.
(c) Qatadah (may Allah have mercy on him) states that one should not recite the tashahhud.
(d) Imam al-Bayhaqi (may Allah have mercy on him) says: The authentic reports on this matter indicate that even when he performed the prostrations after the salam, he did not recite the tashahhud for them. And success is from Allah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3899
Al-Mughirah bin Shu'bah (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) recited the tashahhud after raising his head from the prostrations of forgetfulness.
Muhammad bin Abd al-Rahman bin Abi Layla is alone in narrating this from al-Sha'bi, and what he alone narrates is not to be relied upon. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3900
Hadith Gradingمحدثین:شاذ
Hadith Takhrij«شاذ۔ اخرجه الطبراني في الاوسط 8124»
Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) narrates that the Messenger of Allah (peace and blessings be upon him) said: "When you are praying and you have doubt between three and four (rak'ahs), and your strongest belief is four, recite the tashahhud, then perform two prostrations while sitting before giving the salam, then recite the tashahhud likewise, and then give the salam."
This is not strong, and there is disagreement over whether it is marfu' (attributed to the Prophet) and over its wording.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3901