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.