Hadith 567

وَعَنْ أَنَسٍ قَالَ: جَاءَ رَجُلٌ فَقَالَ يَا رَسُولَ اللَّهِ إِنِّي أَصَبْتُ حَدًّا فأقمه عَليّ قَالَ وَلم يسْأَله عَنهُ قَالَ وَحَضَرَتِ الصَّلَاةُ فَصَلَّى مَعَ رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فَلَمَّا قَضَى النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ الصَّلَاة قَامَ إِلَيْهِ الرَّجُلُ فَقَالَ يَا رَسُولَ اللَّهِ إِنِّي أَصَبْتُ حَدًّا فأقم فِي كتاب الله قَالَ أَلَيْسَ قَدْ صَلَّيْتَ مَعَنَا قَالَ نَعَمْ قَالَ فَإِنَّ اللَّهَ قَدْ غَفَرَ لَكَ ذَنْبَكَ أَو قَالَ حدك
Anas told of a man who came and said, “Messenger of God, I have done something which merits punishment, so appoint it for me.” He did not question him about it, and when the time for prayer came the man prayed along with him. Then when the Prophet had finished the prayer the man got up and said, “Messenger of God, I have done something which merits punishment, so appoint for me that God has decreed.” He asked, “Did you not pray along with us?” and when he replied that he had, he said, “Well, God has forgiven you your offence, or “your punishment”. (Bukhari and Muslim.)
Hadith Reference Mishkat al-Masabih / The Book of Prayer / Hadith: 567
Hadith Grading الألبانی: مُتَّفَقٌ عَلَيْهِ  |  زبیر علی زئی: متفق عليه
Hadith Takhrij ´تحقيق و تخريج: محدث العصر حافظ زبير على زئي رحمه الله` «متفق عليه، رواه البخاري (6833) و مسلم (2764/44)»