Sahih Muslim , Book 37, Hadith 6661 (USC-MSA) ⓘ
Abu Umama reported: We were sitting in the mosque in the company of Allah's Messenger. A person came there and said: Allah's Messenger, I have committed an offence which deserves the imposition of hadd upon me, so impose it upon me. Allah's Messenger kept silent. He repeated it and said: Allah's Messenger, I have committed an offence which deserves the imposition of hadd upon me, so impose it upon me. He (the Holy Prophet) kept silent, and it was at this time that Iqama was pronounced for prayer (and the prayer was observed). And when Allah's Apostle had concluded the payer that person followed Allah's Messenger. Abu Umama said: I too followed Allah's Messenger after he had concluded the prayer, so that I should know what answer he would give to that person. That person remained attached to Allah's Messenger and said: Allah's Messenger, I have committed an offence which deserves imposition of hadd upon me, so impose it upon me. Abu Umama reported that Allah's Messenger said to him: Didn't you see that as you got out of the house, you performed ablution perfectly well. He said: Allah's Messenger, of course. I did it. He again said to him: Then you observed prayer along with us. He said: Allah's Messenger, yes, it is so. Thereupon Allah's Messenger said to him: Verily, Allah has exempted you from the imposition of hadd, or he said. From your sin.
حَدَّثَنَا نَصْرُ بْنُ عَلِيٍّ الْجَهْضَمِيُّ، وَزُهَيْرُ بْنُ حَرْبٍ، - وَاللَّفْظُ لِزُهَيْرٍ - قَالاَ حَدَّثَنَا عُمَرُ بْنُ يُونُسَ، حَدَّثَنَا عِكْرِمَةُ بْنُ عَمَّارٍ، حَدَّثَنَا شَدَّادٌ، حَدَّثَنَا أَبُو أُمَامَةَ، قَالَ بَيْنَمَا رَسُولُ اللَّهِ صلى الله عليه وسلم فِي الْمَسْجِدِ وَنَحْنُ قُعُودٌ مَعَهُ إِذْ جَاءَ رَجُلٌ فَقَالَ يَا رَسُولَ اللَّهِ إِنِّي أَصَبْتُ حَدًّا فَأَقِمْهُ عَلَىَّ . فَسَكَتَ عَنْهُ رَسُولُ اللَّهِ صلى الله عليه وسلم ثُمَّ أَعَادَ فَقَالَ يَا رَسُولَ اللَّهِ إِنِّي أَصَبْتُ حَدًّا فَأَقِمْهُ عَلَىَّ . فَسَكَتَ عَنْهُ وَأُقِيمَتِ الصَّلاَةُ فَلَمَّا انْصَرَفَ نَبِيُّ اللَّهِ صلى الله عليه وسلم قَالَ أَبُو أُمَامَةَ فَاتَّبَعَ الرَّجُلُ رَسُولَ اللَّهِ صلى الله عليه وسلم حِينَ انْصَرَفَ وَاتَّبَعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم أَنْظُرُ مَا يَرُدُّ عَلَى الرَّجُلِ فَلَحِقَ الرَّجُلُ رَسُولَ اللَّهِ صلى الله عليه وسلم فَقَالَ يَا رَسُولَ اللَّهِ إِنِّي أَصَبْتُ حَدًّا فَأَقِمْهُ عَلَىَّ - قَالَ أَبُو أُمَامَةَ - فَقَالَ لَهُ رَسُولُ اللَّهِ صلى الله عليه وسلم " أَرَأَيْتَ حِينَ خَرَجْتَ مِنْ بَيْتِكَ أَلَيْسَ قَدْ تَوَضَّأْتَ فَأَحْسَنْتَ الْوُضُوءَ " . قَالَ بَلَى يَا رَسُولَ اللَّهِ . قَالَ " ثُمَّ شَهِدْتَ الصَّلاَةَ مَعَنَا " . فَقَالَ نَعَمْ يَا رَسُولَ اللَّهِ . قَالَ فَقَالَ لَهُ رَسُولُ اللَّهِ صلى الله عليه وسلم " فَإِنَّ اللَّهَ قَدْ غَفَرَ لَكَ حَدَّكَ - أَوْ قَالَ - ذَنْبَكَ " .
also referenced under: Book 50, Hadith 53 (In-Book) & Hadith 2765 (Reference)