The carrying out of the hadd punishment for a sin for which that punishment has been prescribed is an expiation for that sin.
Sincere repentance from sin is also an expiation for sin, and “the one who repents from sin is like the one who did not sin.” And Allaah will turn his bad deeds into good deeds.
If he is sincere in his repentance, and prays a great deal for forgiveness, then he does not have to confess so that the hadd punishment may be carried out on him. Rather repentance is sufficient, in sha Allaah.
Allaah says (interpretation of the meaning):
“And those who invoke not any other ilaah (god) along with Allaah, nor kill such person as Allaah has forbidden, except for just cause, nor commit illegal sexual intercourse ___ and whoever does this shall receive the punishment.
The torment will be doubled to him on the Day of Resurrection, and he will abide therein in disgrace;
Except those who repent and believe (in Islamic Monotheism), and do righteous deeds; for those, Allaah will change their sins into good deeds, and Allaah is Oft-Forgiving, Most Merciful.
And whosoever repents and does righteous good deeds; then verily, he repents towards Allaah with true repentance”
It was narrated from ‘Ubaadah ibn al-Saamit (may Allaah be pleased with him) that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Give me your oath of allegiance and your pledge that you will not associate anything in worship with Allaah, or steal, or commit adultery, or kill your children, or utter slander, intentionally forging falsehood (i.e. by making illegal children belonging to their husbands) [cf. al-Mumtahanah 60:12], or disobey with regard to anything that is good. Whoever among you fulfils this pledge, Allaah will reward him, and whoever does any of these things and is punished in this world, that will be an expiation for him. Whoever does any of these things and Allaah conceals it for him, then it is up to Allaah: if He wills He will forgive him and if He wills He will punish him.”
Narrated by al-Bukhaari, 18; Muslim, 1709.
In Saheeh Muslim (1695) it says that when Maa’iz came to the Prophet (peace and blessings of Allaah be upon him) and confessed that he had committed zina and said, “Purify me (i.e., carry out the hadd punishment on me)”, he said to him, “Woe to you, go back and ask Allaah for forgiveness and repent to Him.”
Al- Nawawi said:
This hadeeth indicates that the burden of sin is lifted from one who repents from major sins, and this is according to the consensus of the Muslims.
Al-Haafiz Ibn Hajar said:
From this case – i.e. the case of Maa’iz when he confessed zina – it may be understood that it is mustahabb for the one whose case is similar to repent to Allaah and to conceal himself and not mention his sin to anyone… This was affirmed by al-Shaafa’i who said: I prefer for the one who has committed a sin and been concealed by Allaah to conceal it himself and to repent.
Fath al-Baari, 12/124, 125
And it was narrated from ‘Abd-Allaah ibn ‘Umar (may Allaah be pleased with him) that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Avoid these sins that Allaah has forbidden, but whoever does any of them, let him conceal himself with the concealment of Allaah and repent to Allaah, for whoever tells us of what he has done, we will carry out (the punishment prescribed in) the Book of Allaah on him.”
It was also narrated by al-Haakim in al-Mustadrak ‘ala al-Saheehayn (4/425) and by al-Bayhaqi (8/330); classed as saheeh by al-Albaani in Saheeh al-Jaami’, 149.