Anas bin Malik reported,

Abu Bakr was leading them in prayer during the illness from which the Messenger of Allah ﷺ passed away. On Monday, while they were standing in rows for the prayer, the Messenger of Allah ﷺ drew back the curtain of the chamber and looked out at us, standing there with his face like a page of the Quran. Then the Messenger of Allah ﷺ smiled, laughing.We were stunned in the midst of our prayer, overjoyed at the appearance of the Messenger of Allah ﷺ. Abu Bakr stepped back on his heels to join the row, thinking the Messenger of Allah ﷺ was coming out to lead the prayer. But the Messenger of Allah ﷺ gestured to them with his hand to complete their prayer. Then the Messenger of Allah ﷺ went back inside and let the curtain fall.The Messenger of Allah ﷺ passed away that very day.

Muslim 944

Sahih

حدثني عمرو الناقد وحسن الحلواني وعبد بن حميد قال عبد أخبرني وقال الآخران حدثنا يعقوب وهو ابن إبراهيم بن سعد و حدثني أبي عن صالح عن ابن شهاب قال أخبرني

أنس بن مالك

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

مسلم 944صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Prayer
Chapter
Appointing a deputy by the imam when he has an excuse such as illness, travel, or other reasons to lead the people in prayer, and that whoever prays behind an imam who is sitting due to inability to stand must stand if he is able, and the abrogation of sitting behind a sitting imam for those capable of standing
Numbering
Darussalam 944
Muslim 944