Abu Hurairah reported,

The prayer was called and the people formed their rows. The Messenger of Allah ﷺ came out, and when he stood in his place, he remembered that he had not performed the ritual bath. He said to the people, "Stay where you are." Then he returned to his house and came back out to us with water dripping from his head, having bathed, while we remained in our rows.This is the wording of Ibn Harb. In Ayyash's version, he said, "We remained standing, waiting for him, until he came out to us having bathed."

Abu Dawud 235

Sahih

حدثنا عمرو بن عثمان حدثنا محمد بن حرب حدثنا الزبيدي ح و حدثنا عياش بن الأزرق أخبرنا ابن وهب عن يونس ح و حدثنا مخلد بن خالد حدثنا إبراهيم بن خالد إمام مسجد صنعاء حدثنا رباح عن معمر ح و حدثنا مؤمل بن الفضل حدثنا الوليد عن الأوزاعي كلهم عن الزهري عن أبي سلمة

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

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

أبو داود 235صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Abu Dawud
Book
Purification
Chapter
One in a state of major ritual impurity who leads the people in prayer while he is forgetful
Numbering
Darussalam 235
Abu Dawud 235