*510 OPINION
MEYERS, J.,delivered the opinion of the Court,
in which PRICE, KEASLER, HERVEY, and HOLCOMB, JJ, joined.The issue we decide today is whether Applicant should be allowed to raise a claim of illegal sentence based on an improper enhancement for the first time on a writ of habeas corpus, or whether such claim is forfeited by: 1) Applicant’s failure to raise it on direct appeal; or 2) Applicant’s plea of true to such enhancements during the plea proceedings. We conclude that Applicant may raise such a claim and that, in this case, he is entitled to relief.
Facts
Applicant David Alan Rich1 was charged with felony driving while intoxicated. The indictment contained two enhancement paragraphs which alleged pri- or convictions for two felony offenses, delivery of a controlled substance (cause number F-76-10016HL) and injury to an elderly person (cause number 93-42604). In 2002, Applicant pleaded guilty to the offense and true to the enhancement paragraphs pursuant to a plea-bargain agreement. The trial court enhanced his punishment under the habitual-offender provision of Texas Penal Code § 12.42(d) and imposed a sentence of 25 years’ confinement in the Texas Department of Criminal Justice — Correctional Institutions Division.2 No direct appeal was taken.
Applicant filed an application for a writ of habeas corpus claiming that he received ineffective assistance of counsel as a result of his attorney’s failure to investigate the prior convictions used for enhancement. In its Findings of Fact and Conclusions of Law, the trial court determined that Applicant had not been convicted of a felony for the delivery of a controlled substance offense (cause number F-76-10016HL) because the charge was reduced to a misdemeanor after a motion for a new trial was granted. Since a misdemeanor conviction had been improperly used to enhance his sentence, the trial court concluded that the sentence itself was illegal. Despite this finding, the trial court determined that trial counsel’s investigation of the prior convictions was reasonable based on the information available and that Applicant had received effective assistance of counsel at trial.
Subsequently, this Court entered an order requiring the trial court to determine whether there were any other prior felony convictions that could have been substituted for the misdemeanor that was improperly used for enhancement. The trial court filed Supplemental Findings of Fact and Conclusions of Law, finding that neither of Applicant’s other prior felony convictions could have been properly substituted for the prior misdemeanor conviction. The trial court concluded that Ap*511plicant’s third-degree felony could have been enhanced to a second-degree felony, at most. The range of punishment for a second-degree felony is 2 to 20 years pursuant to Texas Penal Code § 12.42(a)(3).
Issue Presented
Both Applicant and the State agree that Applicant has not forfeited his claim of illegal sentence based on an improper enhancement, but they base their arguments on different grounds. We agree with the State that “a defect that renders a sentence void may be raised at any time,”3 and we reject Applicant’s contention that his claim is one of actual innocence with regard to the improper enhancement paragraph. We conclude that Applicant may raise his claim for the first time on an application for a writ of habeas corpus, even though he failed to raise the issue on direct appeal and pleaded true to the enhancement paragraphs.
Analysis
Under Article 11.07 of the Texas Code of Criminal Procedure, post-conviction habeas relief is available for claims involving jurisdictional defects and violations of fundamental or constitutional rights. See Ex parte McCain, 67 S.W.3d 204, 210 (Tex.Crim.App.2002). We have long held that a claim of an illegal sentence is cognizable on a writ of habeas corpus. Mizell v. State, 119 S.W.3d 804, 806 (Tex.Crim.App.2003); Ex parte Pena, 71 S.W.3d at 336-37; Ex parte Beck, 922 S.W.2d 181, 182 (Tex.Crim.App.1996); Ex parte McIver, 586 S.W.2d 851, 854 (Tex.Crim.App.1979). An illegal sentence is distinguishable from a procedural irregularity 4 or an inaccurate judgment,5 neither of which warrant relief on a writ of habeas corpus.
The resolution of this case depends on whether Applicant’s sentence is actually illegal. When the judge delivered the sentence based on the indictment before him, he acted within his authority and the law. It was not until the trial court discovered that one of Applicant’s felony charges had been reduced to a misdemeanor offense that the problem with the sentence became known. Clearly, the trial judge himself did not knowingly act illegally when issuing Applicant’s sentence of 25 years. However, since Applicant’s delivery of a controlled substance offense was reduced to a misdemeanor, as a matter of law, the prior conviction could not be used to sentence him as a habitual offender. Applicant is currently serving the fourth year of an enhanced sentence of 25 years for driving while intoxicated, when the actual range of punishment for his offense with one prior felony conviction is 2 to 20 years.
Our precedents involving claims of illegal sentences have dealt with situations in which the illegality of the judgment was apparent from the facts before the trial court.6 Although the instant case involves *512a different situation because the mischar-acterization of one of the prior convictions only later became known, our previous cases in this area, and the rationale upon which they are based, are not only applicable but also instructive in evaluating Applicant’s claim. We have held that “[a] sentence which is outside the maximum or minimum range of punishment is unauthorized by law and therefore illegal.” Mizell, 119 S.W.3d at 806. The error that occurred in Applicant’s sentencing was more than a clerical mistake that can be corrected by a nunc pro tunc motion and order because it resulted from judicial reasoning or determination. See Ex parte Pena, 71 S.W.3d at 337. Cf. Ex parte Ybarra, 149 S.W.3d 147 (Tex.Crim.App.2004) (dismissing the inmate’s application for a writ of habeas corpus because the trial court had the authority to correct the omission of his pre-sentence jail credit with a nunc pro tunc judgment, and if the trial court failed to respond to his motion, he was required to seek a petition for a writ of mandamus in the Court of Appeals). It is not the trial court’s entry of judgment that is in error,7 but the legality of the punishment as it now stands. The fact that the judicial reasoning and determination were correct according to the facts before the court at the time of sentencing does not preclude a finding of illegality at some later date. Although the judge did not make an incorrect determination based on the information before him, the mischaracterization of the offense in the indictment nevertheless resulted in Applicant’s being sentenced in violation of the law. It was only when the habeas court uncovered the error in the indictment that it was discovered that Applicant’s sentence was illegal. Applicant bargained for a sentence of 25 years for the driving while intoxicated offense when he could, at minimum, have bargained for a sentence of 2 years, and the maximum legal sentence was 20 years. Even as we have increasingly narrowed the types of claims that are cognizable under habeas corpus, our precedents firmly establish that inmates in custody under such an illegal sentence may seek habeas relief.
Because the record on appeal would not have shown that Applicant’s sentence was illegal, it is appropriate for him to challenge it by applying for a writ of habeas corpus. Although habeas corpus is an extraordinary remedy, this is an extraordinary situation. Applicant’s current sentence is more than ten times the minimum, and five years more than the maximum, *513number of years he could have received if the primary offense had been properly enhanced in the indictment. He has already served four years of this improperly enhanced sentence, and he has no other means of obtaining relief. The caselaw makes it clear that Applicant can seek relief by direct appeal or writ of habeas corpus because “a defect which renders a sentence void may be raised at any time.” Ex parte Beck, 922 S.W.2d at 182 (citing Heath v. State, 817 S.W.2d 335, 336 (Tex.Crim.App.1991) (opinion on original submission)); see also Ex parte Miller, 921 S.W.2d at 239; Ex parte White, 659 S.W.2d 434, 435 (Tex.Crim.App.1983); Ex parte McIver, 586 S.W.2d at 854; Ex parte Harris, 495 S.W.2d 231, 232 (Tex.Crim.App.1973). In fact, “there has never been anything in Texas law that prevented any court with jurisdiction over a criminal case from noticing and correcting an illegal sentence,” no matter when or how the relief was sought. Mizell, 119 S.W.3d at 806. The fact that the record on direct appeal would not have revealed that there was a problem with Applicant’s sentence makes habeas corpus the appropriate avenue for affording him relief.8 Applicant did not forfeit his claim to challenge his illegal sentence by failing to raise it on direct appeal.9
Furthermore, Applicant did not forfeit his claim by pleading true to the enhancement paragraphs at the plea proceedings. Despite the general rule that a plea of true to an enhancement paragraph relieves the State of its burden to prove a prior conviction alleged for enhancement and forfeits the defendant’s right to appeal the insufficiency of evidence to prove the prior conviction,10 there is an exception when “the record affirmatively reflects” that the enhancement is itself improper. This exception originated in Sanders v. State, in which the Fourth Court of Appeals held that a prior non-final conviction could not be used to enhance punishment even where the defendant had pleaded true to the enhancement paragraph characterizing the prior offense as final. 785 S.W.2d 445, 448 (Tex.App.-San Antonio 1990, no pet.). “[I]n the interest of justice,” the court of appeals set aside the appellant’s enhanced punishment and remanded the case to the trial court for the proper assessment of punishment. Id. Similarly, the Fourteenth Court of Appeals applied this exception to a case in which the offenses used for enhancement did not occur in the sequence alleged by the indictment. Mikel v. State, 167 S.W.3d 556 (Tex.App.-Houston [14th Dist.] 2005, no *514pet.) (even though the appellant pleaded true at the punishment hearing, the court of appeals concluded that the evidence was legally insufficient to prove the allegations in the improper enhancement paragraph and remanded the case for a new punishment hearing.).11 We agree with the rationale of these decisions by the courts of appeals.
There is a great disparity between the sentence of 25 years for which Applicant pleaded guilty and the possible sentences within the proper range of punishment which he could have received, either by pleading guilty or going to trial.12 When an appellate court finds error at the punishment stage of the trial, the case may be remanded to the trial court for the proper assessment of punishment. Levy v. State, 818 S.W.2d 801, 803 (Tex.Crim.App.1991) (citing Jackson v. State, 680 S.W.2d 809, 814 (Tex.Crim.App.1984); Bullard v. State, 548 S.W.2d 13, 18 (Tex.Crim.App.1977)). In cases in which a defendant enters a plea of guilty or nolo contendere without the benefit of a plea bargain and the trial judge assesses a punishment not authorized by law, the appropriate remedy is to allow the finding of guilt to remain and to remand the case for a new punishment hearing. Levy, 818 S.W.2d at 803. In non-plea bargain cases in which the defendants received sentences that were not authorized by law, such as Sanders and Mikel, the courts of appeals followed our precedent by affirming the appellants’ convictions and remanding the cases for the proper assessment of punishment.
Because Applicant was sentenced pursuant to a negotiated plea bargain and the error in the indictment affected the entirety of the criminal proceeding against him, his situation is dissimilar and requires a different remedy. Indeed, when a plea-bargain agreement calls for a sentence much greater than that authorized by law, we must allow the defendant to withdraw his plea because there is no way of knowing whether the State would have offered a plea bargain within the proper range of punishment that he deemed acceptable, or whether he would have decided to proceed to trial. Furthermore, resentencing alone is not sufficient in this instance because by “attackfing] the sentence he received and for which he bargained, [Applicant] is attacking the entire judgment of conviction.” Shannon v. State, 708 S.W.2d 850, 851 (Tex.Crim.App. *5151986) (holding that “the idea that error is ‘punishment error’ only is incompatible with the negotiated plea and we therefore disavow such analysis in this specific area.”). Although the plea bargain seemed fail’ on its face when executed, it has become unenforceable due to circumstances beyond the control of the Applicant or the State, namely the fact that one of the enhancement paragraphs was mis-characterized in the indictment, resulting in an illegal sentence far outside the statutory range of punishment. See id. at 852. Since neither the State nor the trial court has the authority to ensure compliance with a sentence that so greatly exceeds the statutory range of punishment, the proper remedy is to allow Applicant to withdraw his plea and remand the case to the trial court, putting both parties back in their original positions before they entered into the plea bargain.
Although Applicant bases his argument for relief on actual innocence grounds, we believe that it is not only unnecessary but incorrect to treat this case as if it involves such a claim. Because one of the enhancements underlying Applicant’s sentence was proven to be untrue, Applicant has a claim that is similar to those advanced in actual innocence cases. However, Applicant’s situation should be addressed as a claim of illegal sentence because the mischaracterization of his prior offense affected his sentence, rather than the trial court’s determination of guilt. There is no evidence that Applicant is innocent of the delivery of the controlled substance offense alleged in the enhancement paragraph, and the mischar-acterization of this misdemeanor conviction as a felony does not make him innocent of the primary offense of driving while intoxicated. While we have held that the incarceration of an innocent person is a violation of due process,13 Applicant’s situation does not involve the traditional hallmarks of actual innocence claims — newly discovered evidence showing that the defendant is being wrongfully imprisoned for a crime that he did not commit. Applicant’s incarceration beyond the maximum legal term does not suggest actual innocence of any offense,14 and we can afford him relief from his illegal sentence by applying our precedents and allowing an exception for his plea of true to the improper enhancement paragraph.
Conclusion
In Applicant’s case, the allegation of a prior felony conviction in the first enhancement paragraph is not true. It was this improper enhancement that resulted in Applicant’s illegal sentence of 25 years. In accordance with our precedents affording relief from an illegal sentence at any time, and by making an exception that excuses Applicant’s plea of true to the enhancement paragraph, we conclude that Applicant is entitled to relief. The judgment in this cause is hereby vacated, and Applicant is remanded to the custody of the Sheriff of Denton County to answer the charges set out in the indictment.
WOMACK, J., filed a concurring opinion, in which JOHNSON and COCHRAN, JJ., joined. KELLER, P.J., concurred.. There is a discrepancy in the spelling of Applicant's name. The indictment and judgment against him list his name as "David Alan Rich”; his attorney in this action refers to him as "David Allen Rich"; and his name is listed in his application for a writ of habeas corpus as "David Alen Rich.” We have decided to spell his name as it appears in the indictment and the judgment against him.
. A habitual offender is a person shown to have "previously been finally convicted of two felony offenses, and the second previous felony conviction is for an offense that occurred subsequent to the first previous conviction having become final ...” Tex Penal Code. Ann. § 12.42(d) (Vernon’s Supp.2001). On conviction, a habitual offender "shall be punished by imprisonment in the institutional division of the Texas Department of Criminal Justice for life, or for any term of not more than 99 years or less than 25 years.” Id.
. "A 'void' or ‘illegal’ sentence is one that is not authorized by law.” See Ex parte Pena, 71 S.W.3d 336, 337 (Tex.Crim.App.2002) (citing Ex parte Johnson, 697 S.W.2d 605, 606-07 (Tex.Crim.App.1985)).
. See Ex parte Seidel, 39 S.W.3d 221, 224 (Tex.Crim.App.2001) ("While a judgment is merely ‘voidable for irregularity,’ it is 'void for illegality.’ ” (citing Ex parte White, 50 Tex. Crim. 473, 98 S.W. 850, 851 (Tex.Crim.App. 1906))).
.See Ex parte Pena, 71 S.W.3d at 336-37 ("[A] claim that a judgment is inaccurate, which is neither a claim of jurisdictional defect nor of a violation of constitutional or fundamental rights, is not a basis for habeas relief under article 11.07 of the Texas Code of Criminal Procedure.”).
. See Mizell, 119 S.W.3d at 805 (affirming the court of appeals' decision that a fine of "$0” was not a valid sentence under a statute ^vyhich provided for punishment by "a fine not *512tó exceed $4,000”); Ex parte Miller, 921 S.W.2d 239 (Tex.Crim.App.1996) (holding that the applicant’s sentence was illegal because at the time he committed the offense, Texas law provided that a state jail felony could not be enhanced); Ex parte Beck, 922 S.W.2d at 182 (same); Ex parte Johnson, 697 S.W.2d at 606 (holding that the fine assessed against the applicant was unauthorized because the law did not allow the fine in addition to a sentencing enhancement); Ex parte McIver, 586 S.W.2d at 853-54 (holding that the verdict, judgment, and sentence were "void” because the jury assessed confinement, without a recommendation of probation, and a fine, with a recommendation of probation, and this was not authorized by the statute). Cf. Ex parte McCain, 67 S.W.3d at 211 (holding that a violation of article 1.13(c) of the Texas Code of Criminal Procedure, requiring the appointment of counsel for a defendant charged with a felony before acceptance of his waiver of a jury trial, was not a cognizable habeas issue); Ex parte Pena, 71 S.W.3d at 336 (holding that the applicant’s claim — that a fine included in his written judgment, but not imposed by the jury, was unauthorized— was not cognizable on habeas).
. Ex parte Wingfield, 162 Tex.Crim. 112, 282 S.W.2d 219 (1955) ("if the error was in the entry of judgment and not in the pronouncement, the judgment was not void and was subject to correction by nunc pro tunc proceedings.”).
. It is unnecessary to undertake a harm analysis in the instant case. It is obvious that Applicant has suffered harm because the improper enhancement of his sentence resulted in punishment beyond the statutory maximum.
. While our holdings in Ex parte Nelson, 137 S.W.3d 666 (Tex.Crim.App.2004), and Ex parte Townsend, 137 S.W.3d 79 (Tex.Crim. App.2004), limit the ability of inmates to bring claims on habeas corpus that they could have raised on direct appeal, the facts of Applicant’s case do not present this situation. We have said that inmates may not use the writ of habeas corpus as a substitute for appeal, but in a case where the original record does not show the problem with the proceedings or the punishment, habeas may be used as a substitute for a motion for new trial. In fact, in ineffective assistance of counsel cases, we have said that the preferred method to present these claims is to submit an application for writ of habeas corpus. See, e.g., Robinson v. State, 16 S.W.3d 808, 810 (Tex.Crim.App. 2000).
. Harvey v. State, 611 S.W.2d 108, 111 (Tex.Crim.App.1981); see also O’Dell v. State, 467 S.W.2d 444 (Tex.Crim.App.1971); Latta v. State, 507 S.W.2d 232 (Tex.Crim.App.1974); Dinn v. State, 570 S.W.2d 910 (Tex.Crim.App.1978); Graham v. State, 546 S.W.2d 605 (Tex.Crim.App.1977).
. We also note that the First Court of Appeals, in an unpublished opinion, extended this exception to any case in which the record shows that the prior conviction could not have been used for enhancement purposes, despite the defendant’s plea of true to the enhancement paragraphs. Cruz v. State, No. 01-00-00463-CR, 2001 WL 1168273, at *1, 2001 Tex.App. LEXIS 6654, at *1 (Tex.App.Houston [1st Dist.] Oct. 4, 2001, no pet.) (not designated for publication) (despite appellant’s plea of true to the prior felony conviction of credit card abuse, this conviction could not be used to sentence appellant as a habitual offender because the offense was a state jail felony, which may not be used for enhancement purposes under Tex. Pen.Code Ann. § 12.42(e) as a matter of law).
. While we do not know for sure, Applicant seemed to believe that he was getting a good deal from the State when he was offered the minimum sentence within the range of punishment for a habitual offender. If his prior conviction for the delivery of a controlled substance offense had been properly characterized in the indictment, the State may not have offered him the minimum sentence of 2 years for a second-degree felony, and there would have been no reason for him to accept a plea bargain that gave him the maximum sentence he could have possibly received by going to trial. Although it is impossible to predict with any certainty what sentence he would have received, it probably would have been in the middle section of the 2 to 20 year range, making his illegal sentence of 25 years very disparate.
. Ex parte Elizondo, 947 S.W.2d 202, 205 (Tex.Crim.App.1996).
. Id. at 209 (defendant bears burden of showing that newly discovered evidence unquestionably establishes his innocence).