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.'"
حدثنا محمد بن عبيد حدثنا حماد بن زيد عن أيوب عن محمد
صلى بنا رسول الله ﷺ إحدى صلاتي العشي الظهر أو العصر قال فصلى بنا ركعتين ثم سلم ثم قام إلى خشبة في مقدم المسجد فوضع يديه عليهما إحداهما على الأخرى يعرف في وجهه الغضب ثم خرج سرعان الناس وهم يقولون قصرت الصلاة قصرت الصلاة وفي الناس أبو بكر وعمر فهاباه أن يكلماه فقام رجل كان رسول الله ﷺ يسميه ذا اليدين فقال يا رسول الله أنسيت أم قصرت الصلاة قال لم أنس ولم تقصر الصلاة قال بل نسيت يا رسول الله فأقبل رسول الله ﷺ على القوم فقال أصدق ذو اليدين فأومئوا أي نعم فرجع رسول الله ﷺ إلى مقامه فصلى الركعتين الباقيتين ثم سلم ثم كبر وسجد مثل سجوده أو أطول ثم رفع وكبر ثم كبر وسجد مثل سجوده أو أطول ثم رفع وكبر قال فقيل لمحمد سلم في السهو فقال لم أحفظه عن أبي هريرة ولكن نبئت أن عمران بن حصين قال ثم سلم
Citation, Muslim narrated it in Masajid, chapter on forgetfulness in prayer and the sujud for it, hadith 573, from the narration of Hammad bin Zayd through this chain.