Abu Hurairah reported,

The prayer was called and the rows were straightened in standing position. The Messenger of Allah ﷺ came out to us, and when he stood at his place of prayer, he remembered that he was in a state of major ritual impurity. He said to us, "Stay in your places."Then he went back, performed the full ritual bath, and came out to us with water dripping from his head. He pronounced the takbir, and we prayed with him.Abdul-Ala followed the same chain from Muamar, from Zuhri. Uzai also narrated it from Zuhri.

Bukhari 275

Sahih

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

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

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

البخاري 275صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Ghusl
Chapter
If someone remembers in the masjid that he is in a state of janabah, he leaves as he is and does not perform tayammum
Numbering
Darussalam 275
Bukhari 275