Abdullah bin Umar reported,

The Messenger of Allah ﷺ became absent-minded and ended the prayer with the salam after only two rakats. A man called Dhul-Yadayn said to him, "Messenger of Allah, has the prayer been shortened, or did you forget?"He replied, "It has not been shortened, nor did I forget."Dhul-Yadayn said, "Then you have prayed only two rakats."The Prophet ﷺ turned to the others and asked, "Is it as Dhul-Yadayn says?"They answered, "Yes."So he stepped forward and prayed two more rakats, then made the salam, then performed two prostrations for forgetfulness.

Azami 2477

Sahih

عن عبد الله بن عمر

أن رسول الله ﷺ سها فسلم في الركعتين، فقال له رجل يقال له ذو اليدين: يا رسول الله! أقصرت أو نسيت؟ قال: ما قصرت وما نسيت قال: إذا فصليت ركعتين. قال: أكما يقول ذو اليدين؟ قالوا: نعم. فتقدم فصلى ركعتين، ثم سلم، ثم سجد سجدتي السهو.

الأعظمي 2477صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Forgetfulness
Section
Prostration of forgetfulness after the taslim
Numbering
Jami al-Kamil 2477 (2nd edition)
Azami 2477