A man came to the Messenger of Allah ﷺ and said, "Messenger of Allah, I have committed an offense that requires a prescribed punishment, so carry it out on me."The Prophet turned away from him.The man then said, "I have committed an offense that requires a prescribed punishment, so carry it out on me."The Prophet turned away from him again.The man said once more, "Messenger of Allah, I have committed an offense that requires a prescribed punishment, so carry it out on me."The Prophet turned away from him, and then the prayer was called. After the Prophet ﷺ gave the closing salam, the man stood up 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?"He replied, "Yes."The Prophet asked, "Did you pray with us when we prayed?"He replied, "Yes."The Prophet said, "Then go, for Allah has pardoned you."
حدثنا أبو المغيرة حدثنا الأوزاعي حدثني أبو عمار شداد حدثني
أن رجلا أتى رسول الله ﷺ فقال يا رسول الله إني أصبت حدا فأقمه علي فأعرض عنه ثم قال إني أصبت حدا فأقمه علي فأعرض عنه ثم قال يا رسول الله إني أصبت حدا فأقمه علي فأعرض عنه وأقيمت الصلاة فلما سلم النبي ﷺ قام فقال يا رسول الله إني أصبت حدا فأقمه علي فقال هل توضأت حين أقبلت قال نعم فقال هل صليت معنا حين صلينا قال نعم قال اذهب فإن الله قد عفا عنك
Its chain of transmission is sahih, it has already been mentioned at 22167 and 22063.