A man came to the Prophet ﷺ and said, "Messenger of Allah, I have committed an offense that requires a prescribed punishment, so carry it out on me."The Prophet ﷺ asked, "Did you perform ablution when you came?"The man replied, "Yes."He asked, "Did you pray with us when we prayed?"The man replied, "Yes."The Prophet ﷺ said, "Go, for Allah Most High has pardoned you."
حدثنا محمود بن خالد حدثنا عمر بن عبد الواحد عن الأوزاعي قال حدثني أبو عمار
أن رجلا أتى النبي ﷺ فقال يا رسول الله إني أصبت حدا فأقمه علي قال توضأت حين أقبلت قال نعم قال هل صليت معنا حين صلينا قال نعم قال اذهب فإن الله تعالى قد عفا عنك
Muslim collected it in the Book of Repentance, Chapter on His saying, Most High, "Indeed, good deeds do away with bad deeds", hadith 2765, from the narration of Abu Ammar, and Ibn Khuzayma, hadith 311, from the narration of Uzai with it.