Abu Hurairah reported,

The Messenger of Allah ﷺ led us in one of the afternoon prayers, praying two cycles and then giving the closing salutation. He then stood up and walked over to a piece of wood in the mosque and leaned against it. Some of the people hurried out, saying, "The prayer has been shortened."Among those present were Abu Bakr and Umar, but they were too in awe of him to say anything. Also among the people was a man with long arms known as Ati. He asked, "Messenger of Allah, has the prayer been shortened, or did you forget?"The Prophet ﷺ replied, "It has not been shortened, and I have not forgotten."Ati said, "But you only prayed two cycles."The Prophet ﷺ then asked the people, "Is it as Ati says?"They answered, "Yes."So he stood and prayed two more cycles, then gave the closing salutation, then performed two prostrations, then gave the salutation again.

Ibn Majah 1214

Sahih

حدثنا علي بن محمد حدثنا أبو أسامة عن ابن عون عن ابن سيرين

عن أبي هريرة قال

صلى بنا رسول الله ﷺ إحدى صلاتي العشي ركعتين ثم سلم ثم قام إلى خشبة كانت في المسجد يستند إليها فخرج سرعان الناس يقولون قصرت الصلاة وفي القوم أبو بكر وعمر فهاباه أن يقولا له شيئا وفي القوم رجل طويل اليدين يسمى ذا اليدين فقال يا رسول الله أقصرت الصلاة أم نسيت فقال لم تقصر ولم أنس قال فإنما صليت ركعتين فقال أكما يقول ذو اليدين فقالوا نعم فقام فصلى ركعتين ثم سلم ثم سجد سجدتين ثم سلم

ابن ماجه 1214صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
Regarding one who gave salaam after two or three rakaat forgetfully
Numbering
Darussalam 1214
Ibn Majah 1214