Sayyiduna Anas (may Allah be pleased with him) said: I was with the Prophet (peace and blessings be upon him) when a man came and said: "O Messenger of Allah! I have committed something that carries a hadd, so carry out the hadd on me." He (peace and blessings be upon him) did not ask him anything, and the time for prayer came, so he too prayed with the Prophet (peace and blessings be upon him). When the prayer was finished, the man stood up again and repeated what he had said before. He (peace and blessings be upon him) said: "Did you not pray with us?" He said: Yes. So he (peace and blessings be upon him) said: "Allah has forgiven your sin."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الأشربة والحد فيها / 17621