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