Abu Hurairah reported,

The Messenger of Allah ﷺ led us in one of the two afternoon prayers, either Dhuhr or Asr. He prayed two rakahs with us, then gave the salam. He then stood up and went to a piece of wood at the front of the mosque and placed his hands upon it, one over the other, with anger visible on his face.The people who were quick to leave departed, saying, "The prayer has been shortened, the prayer has been shortened."Among the people were Abu Bakr and Umar, but they were too in awe of him to speak to him. Then a man whom the Messenger of Allah ﷺ used to call Dhul Yadayn stood up and said, "Messenger of Allah, did you forget, or has the prayer been shortened?"He replied, "I have not forgotten, nor has the prayer been shortened."Dhul Yadayn said, "Rather, you have forgotten, Messenger of Allah."The Messenger of Allah ﷺ then turned to the people and asked, "Has Dhul Yadayn spoken truthfully?"They gestured, meaning yes. So the Messenger of Allah ﷺ returned to his place and prayed the two remaining rakahs, then gave the salam. Then he said the takbir and prostrated like his usual prostration or longer, then he raised his head and said the takbir. Then he said the takbir again and prostrated like his usual prostration or longer, then he raised his head and said the takbir.It was said to Muhammad, "Did he give the salam after the forgetfulness?"He replied, "I did not memorize this from Abu Hurairah, but I was informed that Imran bin Husayn said, 'Then he gave the salam.'"

Abu Dawud 1008

Sahih

حدثنا محمد بن عبيد حدثنا حماد بن زيد عن أيوب عن محمد

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

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

أبو داود 1008صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Abu Dawud
Book
Prayer
Chapter
Forgetfulness in the two prostrations
Numbering
Darussalam 1008
Abu Dawud 1008