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.'" (PT)
English reference (PT): Vol. 1, Book 5, Hadith 1220 (PT)
Arabic reference (PT): Book 5, Hadith 1277 (PT)