كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(19)
Chapter: As-Sahw (forgetfulness) in prayer and prostrating to compensate for it
(19)
باب السَّهْوِ فِي الصَّلاَةِ وَالسُّجُودِ لَهُ ‏
Sahih Muslim 573 a

Ibn Sirin reported Abu Huraira as saying:

The Messenger of Allah (ﷺ) led us in one of the two evening prayers, Zuhr or `Asr, and gave salutations after two rak`ahs and going towards a piece of wood which was placed to the direction of the Qibla in the mosque, leaned on it looking as if he were angry. Abu Bakr and `Umar were among the people and they were too afraid to speak to him and the people came out in haste (saying): The prayer has been shortened. But among them was a man called Dhul-Yadain who said: Messenger of Allah, has the prayer been shortened or have you forgotten? The Apostle of Allah (ﷺ) looked to the right and left and said: What was Dhul-Yadain saying? They said: He is right. You (the Holy Prophet) offered but two rak`ahs. He offered two (more) rak`ahs and gave salutation, then said takbir and prostrated and lifted (his head) and then said takbir and prostrated, then said takbir and lifted (his head). He (the narrator) says: It has been reported to me by `Imran b. Husain that he said: He (then) gave salutation.
حَدَّثَنِي عَمْرٌو النَّاقِدُ، وَزُهَيْرُ بْنُ حَرْبٍ، جَمِيعًا عَنِ ابْنِ عُيَيْنَةَ، - قَالَ عَمْرٌو حَدَّثَنَا سُفْيَانُ بْنُ عُيَيْنَةَ، - حَدَّثَنَا أَيُّوبُ، قَالَ سَمِعْتُ مُحَمَّدَ بْنَ سِيرِينَ، يَقُولُ سَمِعْتُ أَبَا هُرَيْرَةَ، يَقُولُ صَلَّى بِنَا رَسُولُ اللَّهِ صلى الله عليه وسلم إِحْدَى صَلاَتَىِ الْعَشِيِّ إِمَّا الظُّهْرَ وَإِمَّا الْعَصْرَ فَسَلَّمَ فِي رَكْعَتَيْنِ ثُمَّ أَتَى جِذْعًا فِي قِبْلَةِ الْمَسْجِدِ فَاسْتَنَدَ إِلَيْهَا مُغْضَبًا وَفِي الْقَوْمِ أَبُو بَكْرٍ وَعُمَرُ فَهَابَا أَنْ يَتَكَلَّمَا وَخَرَجَ سَرَعَانُ النَّاسِ قُصِرَتِ الصَّلاَةُ فَقَامَ ذُو الْيَدَيْنِ فَقَالَ يَا رَسُولَ اللَّهِ أَقُصِرَتِ الصَّلاَةُ أَمْ نَسِيتَ فَنَظَرَ النَّبِيُّ صلى الله عليه وسلم يَمِينًا وَشِمَالاً فَقَالَ ‏ "‏ مَا يَقُولُ ذُو الْيَدَيْنِ ‏"‏ ‏.‏ قَالُوا صَدَقَ لَمْ تُصَلِّ إِلاَّ رَكْعَتَيْنِ ‏.‏ فَصَلَّى رَكْعَتَيْنِ وَسَلَّمَ ثُمَّ كَبَّرَ ثُمَّ سَجَدَ ثُمَّ كَبَّرَ فَرَفَعَ ثُمَّ كَبَّرَ وَسَجَدَ ثُمَّ كَبَّرَ وَرَفَعَ ‏.‏ قَالَ وَأُخْبِرْتُ عَنْ عِمْرَانَ بْنِ حُصَيْنٍ أَنَّهُ قَالَ وَسَلَّمَ ‏.‏
Reference : Sahih Muslim 573a
In-book reference : Book 5, Hadith 126
USC-MSA web (English) reference : Book 4, Hadith 1182
  (deprecated numbering scheme)