It wasnarrated that Abu Hurairah said:
"The Prophet (ﷺ) came outtopray and said the Takbir, then he gestured to them to wait. He wentand took a bath, and his head was dripping with water while he ledthem in prayer. When he finished he said: 'I came out to you in astate of sexual impurity, and I forgot until I had started to pray.'" (JA)
English reference (JA): Vol. 1, Book 5, Hadith 1220 (JA)
Arabic reference (JA): Book 5, Hadith 1277 (JA)