Hadithcore
Riyad as-Salihin, 435

Anas bin Malik (May Allah be pleased with him) reported:

A man came to the Prophet (ﷺ) and said, "O Messenger of Allah, I have committed a sin liable of ordained punishment. So execute punishment on me". Messenger of Allah (ﷺ) did not ask him about it, and then came the (time for) Salat (prayers). So he performed Salat with Messenger of Allah (ﷺ). When Messenger of Allah (ﷺ) finished Salat, the man stood up and said: "O Messenger of Allah! I have committed a sin. So execute the Ordinance of Allah upon me". He (ﷺ) asked, "Have you performed Salat with us?" "Yes", he replied. Messenger of Allah (ﷺ) said, "Verily, Allah has forgiven you". <b>[Al-Bukhari and Muslim]</b>.

وعن أنس، رضي الله عنه ، قال‏:‏ جاء رجل إلى النبي، صلى الله عليه وسلم فقال‏:‏ يا رسول الله أصبت حداً، فأقمه علي، وحضرت الصلاة، فصلى مع رسول الله، صلى الله عليه وسلم، فلما قضى الصلاة قال ‏:‏ يارسول الله إنى أصبت حداً، فأقم في كتاب الله‏.‏ قال “هل حضرت معنا الصلاة‏؟‏‏

‏ قال‏:‏ نعم ‏.‏ قال‏:‏ قد غفر لك‏

‏ ‏(‏‏(‏متفق عليه‏)‏‏)‏‏.‏ ('‏وقوله ‏ ‏اصبت حداً‏ ‏ معناه ‏:‏ معصية توجب التعزير، وليس المراد الحد الشرعي الحقيقى كحد الزنا والخمر وغيرهما، فإن هذه الحدود لا تسقط بالصلاة، ولا يجوز للإمام تركها')

References1 variant
In-Book Reference
Introduction, Hadith 435
Sharh · explanationclick to expand
<b>Guidance from the Hadith:</b><br> 1) If a person performs the prayer in the proper prescribed manner, following the Prophet’s example inwardly and outwardly, then this act of worship expiates his sins, even if they are great.<br> 2) Allah is merciful to His servants, as He has opened to them the doors to expiation of sins, one of which is prayer.
Related hadiths4
Compare isnād across 4 related chains →