Will the repentance of one who impugns the Prophet (blessings and peace of Allah be upon him) be accepted? And is it better to admit it to the qaadi (judge)?
Question

                With regard to the Muslim who impugns the Prophet (blessings and peace of Allah be upon him) in secret and conceals that: if he repents before he is executed, will Allah accept his repentance so that he becomes a Muslim, because he had become a kaafir? Or does he have to announce what he did so that he will be executed before Allah will accept his return to Islam?
Praise be to Allah.Firstly: 
Testifying that the Prophet (blessings and peace of Allah be upon him) is the Messenger of Allah is one of the pillars of Islam. The Muslims are commanded to venerate and love their Prophet (blessings and peace of Allah be upon him) and he is deserving of that, because of the lofty status he has before Allah, and because of the favours he has done to this ummah, for he was the cause of their being brought out of their state of ignorance and he was the cause of their attaining all that is good. How could any Muslim have the audacity, in spite of that, to impugn the Prophet (blessings and peace of Allah be upon him)? 
Hence the scholars are unanimously agreed that the one who impugns the Prophet (blessings and peace of Allah be upon him) is a kaafir and apostate who has gone beyond the pale of Islam. 
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: 
Impugning Allah or impugning His Messenger is kufr both inwardly and outwardly, regardless of whether the one who does that believes that it is haraam or he thinks that it is permissible for him, or he was not thinking of the ruling when he did that. This is the view of the fuqaha’ and all of Ahl as-Sunnah who say that faith is comprised of both words and deeds. 
As-Saarim al-Maslool, 1/513 
It says in al-Mawsoo‘ah al-Fiqhiyyah (40/61): 
The Holy Qur’an tells us that it is a grave sin to disparage the Prophet (blessings and peace of Allah be upon him) or belittle him, and the one who does that is cursed. That is in the verses in which Allah, may He be exalted, says (interpretation of the meaning):
“Verily, those who annoy Allah and His Messenger (SAW) Allah has cursed them in this world, and in the Hereafter, and has prepared for them a humiliating torment”
[al-Ahzaab 33:57]
“If you ask them (about this), they declare: We were only talking idly and joking. Say: Was it at Allah and His Ayat (proofs, evidences, verses, lessons, signs, revelations, etc.) and His Messenger (SAW) that you were mocking? 
Make no excuse; you have disbelieved after you had believed. If We pardon some of you, We will punish others amongst you because they were Mujrimoon (disbelievers, polytheists, sinners, criminals, etc.)”
[at-Tawbah 9:65-66].
The fuqaha’ are of the view that the one who does any of these things is to be regarded as a kaafir. End quote. 
It also says (22/184): 
The ruling on the one who impugns him (blessings and peace of Allah be upon him) is that he is an apostate, and there is no difference of scholarly opinion concerning that. End quote. 
If the one who impugns the Prophet (blessings and peace of Allah be upon him) is an apostate, then the punishment prescribed for him in sharee‘ah is execution; there is no difference of scholarly opinion concerning that. 
Ibn al-Mundhir (may Allah have mercy on him) said: 
The majority of scholars are agreed that the one who impugns the Prophet (blessings and peace of Allah be upon him) is to be executed. End quote. 
See: Tafseer al-Qurtubi, 8/82 
Al-Khattaabi (may Allah have mercy on him) said: 
I do not know of any of the Muslims who differed concerning the obligation of executing him. End quote. 
Ma‘aalim as-Sunan, 3/295 
Secondly: 
If the one who impugned the Prophet (blessings and peace of Allah be upon him) repents and regrets what he did, and he comes back to Islam, that repentance will benefit him in his relationship with Allah. So before Allah he will be a believing Muslim. But with regard to his execution, the obligation of executing him will not be waived. So he will be killed as a Muslim, and he should be washed, the funeral prayer should be offered for him, he may be inherited from and he should be buried in the Muslim graveyard. As for the apostate who did not come back to Islam, he is to be executed as a kaafir. 
Shaykh Muhammad ibn Saalih al-‘Uthaymeen (may Allah have mercy on him) was asked: 
Will the repentance of one who impugned Allah, may He be exalted and glorified, or who reviled the Messenger (blessings and peace of Allah be upon him) be accepted? 
He replied: 
There is a difference of scholarly opinion concerning that, and there are two opinions: 
(i)
The first opinion is that repentance will not be accepted from the one who impugned Allah or His Messenger (blessings and peace of Allah be upon him). This is the well-known view of the Hanbalis. Rather he is to be executed as a kaafir, and the funeral prayer is not to be offered for him and supplication is not to be offered for mercy for him, and he is to be buried in a place far away from the Muslim graves. 
(ii)
The second opinion is that the repentance of one who had reviled Allah or His Messenger (blessings and peace of Allah be upon him) will be accepted if it is known that he has sincerely repented to Allah, and he admits that he made a mistake and speaks of Allah, may He be exalted, in a way that reflects the veneration He deserves. This is because of the general meaning of the evidence that indicates that repentance is accepted, such as the verse in which Allah, may He be exalted, says (interpretation of the meaning): “Say: O ‘Ibaadi (My slaves) who have transgressed against themselves (by committing evil deeds and sins)! Despair not of the Mercy of Allaah, verily, Allaah forgives all sins” [al-Zumar 39:53]. There are some of the kuffaar who impugn Allah, yet despite that their repentance is accepted. This is the correct view. The repentance of one who impugned the Messenger (blessings and peace of Allah be upon him) is accepted, but he must be executed. This is unlike the one who impugns Allah; his repentance is accepted but he is not to be executed, because Allah has told us that He forgives transgressions against His rights if the person repents, and that He forgives all sins. As for the one who impugns the Messenger (blessings and peace of Allah be upon him), there are two matters to be taken into consideration: 
(a)The first is a shar‘i matter, because he is the Messenger of Allah (blessings and peace of Allah be upon him). From this angle, he repentance will be accepted if he repents.
(b)The second is a personal matter. From this nagle, repentance will not be accepted, because it has to do with the right of a human being, and it is not known whether he would forgive it. On that basis he is to be executed, but if he is executed, we should wash him, shroud him, offer the funeral prayer for him and bury him with the Muslims.
This is the view favoured by Shaykh al-Islam Ibn Taymiyah, who wrote a book on that entitled as-Saarim al-Maslool fi Tahattum Qatli Saabb ar-Rasool. That is because he has transgressed against the rights of the Messenger (blessings and peace of Allah be upon him). By the same token, if he were to slander the Prophet (blessings and peace of Allah be upon him), he is to be executed and not flogged. 
If it is asked: Has it not been proven that some of the people impugned the Messenger (blessings and peace of Allah be upon him) during his lifetime and the Prophet (blessings and peace of Allah be upon him) accepted their repentance? 
The answer is: This is true, but that was during his lifetime (blessings and peace of Allah be upon him), and he waived what was due to him. But after his death, no one has the right to waive what is due to him (blessings and peace of Allah be upon him). So we must do what is required if he (blessings and peace of Allah be upon him) is impugned, which is to execute the one who impugns him and to believe that the repentance of the one who does that is accepted with regard to the relationship between that person and Allah, may He be exalted. 
If it is asked: If it was possible that he (the Prophet (blessings and peace of Allah be upon him)) would let him off if that happened during his lifetime, doesn’t that dictate that we should refrain from passing judgement on him? 
My response is: That does not dictate that we should refrain, because evil has occurred by his impugning him, and it is not known whether the effect of that impugning will be removed; the basic principle is that it remains. 
If it is asked: Wasn’t it usually the case that the Messenger (blessings and peace of Allah be upon him) let off those who impugned him? 
My response is: Yes indeed, and perhaps letting them off during the lifetime of the Messenger (blessings and peace of Allah be upon him) was done to serve a purpose, which was to soften people’s hearts towards Islam, as he (blessings and peace of Allah be upon him) knew the identities of the hypocrites but he did not execute them, “lest people say that Muhammad kills his companions.” But nowadays if we know that a specific individual is one of the hypocrites, we should execute him. Ibn al-Qayyim (may Allah have mercy on him) said: Refraining from killing a known hypocrite was only done during the lifetime of the Messenger (blessings and peace of Allah be upon him). End quote. 
Majmoo‘ Fataawa ash-Shaykh al-‘Uthaymeen, 2/150-152 
But… So long as the matter has not reached the qaadi (judge), what is prescribed is for the Muslim to conceal himself (his sins) and not go to the judge to confess his crime; rather he should strive hard to repent and seek forgiveness, and do a lot of good deeds, so that Allah will forgive him. Allah, may He be exalted, says (interpretation of the meaning):
“And verily, I am indeed Forgiving to him who repents, believes (in My Oneness, and associates none in worship with Me) and does righteous good deeds, and then remains constant in doing them, (till his death)”
[Ta-Ha 20:82]
“Then, verily! Your Lord for those who do evil (commit sins and are disobedient to Allah) in ignorance and afterward repent and do righteous deeds, verily, your Lord thereafter, (to such) is Oft-Forgiving, Most Merciful”
[an-Nahl 16:119]. 
And Allah knows best.