Once the call (Iqama) for the prayer was announced and the rows were straightened. Allah's…

Sahih al-Bukhari Book 5 Hadith 27

Sahih al-Bukhari #275

Bathing (Ghusl) 5:27

Narrated Abu Huraira:

Once the call (Iqama) for the prayer was announced and the rows were straightened. Allah's Messenger (ﷺ) came out; and when he stood up at his Musalla, he remembered that he was Junub. Then he ordered us to stay at our places and went to take a bath and then returned with water dropping from his head. He said, "Allahu-Akbar", and we all offered the prayer with him.

Chapter: If someone while in the mosque remembers that he is Junub, he should leave (the mosque to take a bath) and should not perform Tayammum

Grade: Sahih