The Messenger of Allah ﷺ became forgetful and gave the closing salutation after only two rak'ahs. A man known as Dhul-Yadayn said to him, "Messenger of Allah, has the prayer been shortened, or have you forgotten?"He replied, "It has not been shortened, nor have I forgotten."Dhul-Yadayn said, "Then you have prayed only two rak'ahs."The Prophet ﷺ asked the others, "Is it as Dhul-Yadayn says?"They answered, "Yes."So he stepped forward and prayed two more rak'ahs, then gave the closing salutation, and then performed two prostrations for forgetfulness.
حدثنا علي بن محمد وأبو كريب وأحمد بن سنان قالوا حدثنا أبو أسامة عن عبيد الله بن عمر عن نافع
أن رسول الله ﷺ سها فسلم في الركعتين فقال له رجل يقال له ذو اليدين يا رسول الله أقصرت أم نسيت قال ما قصرت وما نسيت قال إذا فصليت ركعتين قال أكما يقول ذو اليدين قالوا نعم فتقدم فصلى ركعتين ثم سلم ثم سجد سجدتي السهو