Abu Hurairah reported,

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.

Nasai 793

Sahih

أخبرنا عمرو بن عثمان بن سعيد بن كثير قال حدثنا محمد بن حرب عن الزبيدي عن الزهري والوليد عن الأوزاعي عن الزهري عن أبي سلمة

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

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

النسائي 793صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Leadership
Chapter
Imam remembers after standing in his place of prayer that he is not in a state of purity
Numbering
Darussalam 793
Nasai 793