Sunan Ibn Majah, Volume 2, Book 5, Hadith 1220 (DarusSalam) ⓘ
It was narrated that Abu Hurairah said: “The Prophet came out to pray and said the Takbir, then he gestured to them to wait. He went and took a bath, and his head was dripping with water while he led them in prayer. When he finished he said: ‘I came out to you in a state of sexual impurity, and I forgot until I had started to pray.’”
حَدَّثَنَا يَعْقُوبُ بْنُ حُمَيْدِ بْنِ كَاسِبٍ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُوسَى التَّيْمِيُّ، عَنْ أُسَامَةَ بْنِ زَيْدٍ، عَنْ عَبْدِ اللَّهِ بْنِ يَزِيدَ، مَوْلَى الأَسْوَدِ بْنِ سُفْيَانَ عَنْ مُحَمَّدِ بْنِ عَبْدِ الرَّحْمَنِ بْنِ ثَوْبَانَ، عَنْ أَبِي هُرَيْرَةَ، قَالَ خَرَجَ النَّبِيُّ ـ صلى الله عليه وسلم ـ إِلَى الصَّلاَةِ وَكَبَّرَ ثُمَّ أَشَارَ إِلَيْهِمْ فَمَكَثُوا ثُمَّ انْطَلَقَ فَاغْتَسَلَ وَكَانَ رَأْسُهُ يَقْطُرُ مَاءً فَصَلَّى بِهِمْ فَلَمَّا انْصَرَفَ قَالَ " إِنِّي خَرَجْتُ إِلَيْكُمْ جُنُبًا وَإِنِّي نَسِيتُ حَتَّى قُمْتُ فِي الصَّلاَةِ " .
also referenced under: Hadith 1220 (Reference) & Book 5, Hadith 1277 (In-Book)