عن أنس رضي الله عنه مرفوعاً: جاء رجل إلى النبي صلى الله عليه وسلم فقال: يا رسول الله، أصَبْتُ حدًّا، فَأَقِمْه عليَّ، وحضرت الصلاة، فصلى مع رسول الله صلى الله عليه وسلم فلمَّا قضى الصلاة، قال: يا رسول الله، إني أصَبْتُ حَدًّا فأقم فيَّ كتاب الله. قال: «هل حَضَرْتَ مَعَنَا الصلاة»؟ قال: نعم. قال: «قد غُفِر لك».
[صحيح] - [متفق عليه]
المزيــد ...
Anas (may Allah be pleased with him) reported: A man came to the Prophet (may Allah's peace and blessings be upon him) and said: "O Messenger of Allah, I committed a sin liable to a legal punishment, so inflict it upon me." As the time of the prayer came, he offered the prayer along with the Messenger of Allah (may Allah’s peace and blessings be upon him. When the prayer was over, he said: "O Messenger of Allah, I committed a sin liable to a legal punishment, so apply the Book of Allah to me." He asked: "Have you offered the prayer with us?’ He said: 'Yes.’ He said: "You have been forgiven."
[Authentic hadith] - [Narrated by Bukhari & Muslim]
A man came and said: “O Messenger of Allah, I did something that entails the imposition of a legal punishment.” Anas (may Allah be pleased with him) said: “He did not ask about it”, meaning: the sin that entailed the legal punishment, because, as believed by some, he already came to know through divine revelation about the sin committed by this man as well as that he was forgiven. “As the time of the prayer came, he offered the prayer along with the Messenger of Allah (may Allah’s peace and blessings be upon him). The prayer here refers to one of the obligatory prayers or the ‘Asr prayer in particular. After finishing the prayer, the man got up and said: “O Messenger of Allah, I committed a sin liable to a legal punishment, so apply the Book of Allah to me”, meaning: the relevant divine ruling based on the Qur’an and the Sunnah. In other words, apply to me whatever is applicable in my case, be it a legal punishment or something else. Thereupon, the Prophet, may Allah's peace and blessings be upon, asked: “Have you not offered the prayer with us?” As the man replied in the affirmative, the Prophet (may Allah's peace and blessings be upon him) said: “Indeed, Allah has forgiven your sin – or pardoned your legal punishment.” The sub-narrator was doubtful about it. The legal punishment, here, may involve a discretionary penalty or something else, but it does not refer to such prescribed punishments as applicable in the cases of adultery and drinking alcohol, for example. The Prophet (may Allah's peace and blessings be upon him) did not ask the man about the specific sin he had committed, for he had learned about some excuse for him, and so he wanted to spare him the due punishment; and if he had asked him about it, he would necessarily have imposed the punishment on him, even if he had repented. Indeed, repentance does not cancel out the prescribed punishments, except in the case of highway robbery, based on the relevant verse, and the commission of adultery by a non-Muslim living in the Muslim land, should he embrace Islam. Anyway, the Hadīth does not explicitly mention that prayer expiated a major sin. Even if this was the case, it should be subject to allegorical interpretation given the previously cited consensus on the contrary.