Anas bin Malik reported,

A man came to the Prophet ﷺ and said, "Messenger of Allah, I have committed an offense deserving a prescribed punishment, so carry it out on me."The time for prayer arrived, and he prayed with the Messenger of Allah ﷺ. When the prayer was finished, the man said, "Messenger of Allah, I have committed an offense deserving a prescribed punishment, so apply to me what is in the Book of Allah."The Prophet ﷺ asked, "Did you pray with us just now?"He replied, "Yes."The Prophet ﷺ said, "You have been forgiven."

Muslim 7006

Sahih

حدثنا الحسن بن علي الحلواني حدثنا عمرو بن عاصم حدثنا همام عن إسحق بن عبد الله بن أبي طلحة

عن أنس قال

جاء رجل إلى النبي ﷺ فقال يا رسول الله أصبت حدا فأقمه علي قال وحضرت الصلاة فصلى مع رسول الله ﷺ فلما قضى الصلاة قال يا رسول الله إني أصبت حدا فأقم في كتاب الله قال هل حضرت الصلاة معنا قال نعم قال قد غفر لك

مسلم 7006صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Tawba
Chapter
His saying, "Indeed good deeds remove bad deeds"
Numbering
Darussalam 7006
Muslim 7006