The prayer was called and the people lined up in their rows. The Messenger of Allah ﷺ came out, but when he stood at his place of prayer, he remembered that he had not performed the ritual bath. He said to the people, "Stay where you are."He then returned to his house and came back out to us with water dripping from his head. He had bathed while we remained standing in our rows.
أخبرنا عمرو بن عثمان بن سعيد بن كثير قال حدثنا محمد بن حرب عن الزبيدي عن الزهري والوليد عن الأوزاعي عن الزهري عن أبي سلمة
أقيمت الصلاة فصف الناس صفوفهم وخرج رسول الله ﷺ حتى إذا قام في مصلاه ذكر أنه لم يغتسل فقال للناس مكانكم ثم رجع إلى بيته فخرج علينا ينطف رأسه فاغتسل ونحن صفوف
Muslim narrated it in the Book of Mosques, chapter "When Should People Stand for Prayer?", hadith no. 158/605, from the hadith of Walid bin Muslim. Bukhari narrated it in the Book of the Adhan, chapter "If the Imam Says, 'Stay in Your Places Until We Return,' Wait for Him," hadith no. 640, from the hadith of Uzai, with the same chain. It is also found in Al-Kubra, hadith no. 867.