‘Umar b. al-Khattab said to the Messenger of Allah (May peace be upon him) that he became sexually defiled at night (asking him what he should do). The Messenger of Allah (May peace be upon him) said : You should perform ablution and wash your penis and then sleep. (Using translation from Abū Dāʾūd 221)
حَدَّثَنَا الْقَعْنَبِيُّ عَنْ مَالِكٍ عَنْ عَبْدِ اللَّهِ بْنِ دِينَارٍ عَنِ ابْنِ عُمَرَ أَنَّهُ قَالَ ذَكَرَ عُمَرُ بْنُ الْخَطَّابِ لِرَسُولِ اللَّهِ ﷺ أَنَّهُ تُصِيبُهُ الْجَنَابَةُ مِنَ اللَّيْلِ فَقَالَ رَسُولُ اللَّهِ ﷺ «تَوَضَّأْ وَاغْسِلْ ذَكَرَكَ ثُمَّ نَمْ»