*306Samuel Lanier appeals the circuit court's summary dismissal of his petition for postconviction relief filed pursuant to Rule 32, Ala. R. Crim. P., in which he attacked his August 2016 resentencing to 25 years' imprisonment for his 1996 guilty-plea conviction for first-degree robbery. Lanier did not appeal his 1996 guilty-plea conviction or his 2016 resentencing.
In his petition, Lanier alleged that he had filed a previous Rule 32 petition challenging his 1996 conviction and the legality of the original sentence imposed for that conviction -- which he had asserted was 5 years' imprisonment and below the mandatory minimum sentence for a Class A felony during which a firearm is used -- and that the circuit court, instead of "withdrawing" that conviction for use for sentence enhancement for his subsequent convictions, set aside the sentence on the ground that it was illegal and resentenced him in August 2016 to 25 years' imprisonment.1 (C. 12.) Lanier alleged that the circuit court lacked jurisdiction to resentence him in 2016 for his 1996 conviction, even though the original sentence was illegal, because, he said: (1) his original sentence had expired before he was resentenced; and (2) he was not represented by counsel at the resentencing hearing.
Without receiving a response from the State, the circuit court summarily dismissed Lanier's petition, finding that Lanier had originally been sentenced to 12 years' imprisonment for his 1996 conviction, not 5 years' imprisonment as Lanier alleged; that the original sentence had been split and Lanier had been ordered to serve 2 years in confinement followed by probation; and that Lanier's sentence had not expired before he was resentenced in 2016 because the court did "not see any indication" that Lanier's probation had been revoked after he had served the confinement portion of his sentence or that Lanier had ever served in confinement the remaining 10 years of his sentence. (C. 19.) The court also found that Lanier was represented by counsel at the resentencing hearing. Because the record before this Court was not sufficient for us to review the propriety of the circuit court's findings, we remanded this case by order dated April 10, 2018, for the circuit court to supplement the record with documentation relating to Lanier's 1996 conviction, his prior Rule 32 petition, and his resentencing. The circuit court promptly complied with our instructions, and this cause was resubmitted on return to remand on April 17, 2018.
On appeal, Lanier reasserts the two claims from his petition and argues that the circuit court erred in denying him relief from his resentencing. Lanier's claim that he was not represented by counsel at his August 2016 resentencing is meritless. The transcript of the resentencing hearing clearly reflects that Lanier was, in fact, represented by counsel. Therefore, the circuit court properly dismissed this claim. See Rule 32.7(d), Ala. R. Crim. P.
*307However, Lanier's claim that the circuit court lacked jurisdiction to resentence him after his original sentence had expired is more problematic. Initially, we point out that, although the State concedes on appeal that Lanier's original sentence had expired before he was resentenced, the circuit court found otherwise. In its summary-dismissal order, the circuit court found that Lanier had served the confinement portion of his original sentence but that his probation had never been revoked and he had never served the remaining 10 years of his 12-year sentence. Those factual findings are supported by the record. The record reflects that Lanier was sentenced to 12 years' imprisonment, that the sentence was split, and that Lanier was ordered to serve 2 years in confinement followed by 3 years on probation. Lanier was also given 468 days of jail credit. The confinement portion of Lanier's sentence began in January 1996, and, after completing that portion of his sentence, he was released to serve the probationary portion of his sentence. On October 31, 1996, Lanier's probation officer filed a delinquency report alleging that Lanier had violated the terms of his probation by committing a new offense, and the trial court ordered Lanier's arrest, but two weeks later, after a probation-revocation hearing, the trial court reinstated Lanier's probation, and the record reflects no further action with respect to Lanier's probationary term.2
Although the circuit court was correct that Lanier's probation was never revoked and that he did not serve in confinement the entirety of his 12-year sentence, the court's conclusion, based on those facts, that Lanier's sentence had not expired was erroneous. In Woodward v. State, 3 So.3d 941, 944 (Ala. Crim. App. 2008), this Court recognized that a probationary period ends when (1) the probationer satisfactorily fulfills all the conditions of probation and the probationary term ordered by the court expires; (2) the maximum period of probation allowed by law expires, even if the probationer has not fulfilled the conditions of probation; or (3) the court formally discharges the probationer from probation. In this case, there is no indication that Lanier fulfilled the conditions of his probation or that the court formally discharged him from probation. However, the record is clear that the maximum period of probation allowed by law expired before Lanier was resentenced.
When a defendant is sentenced pursuant to the Split Sentence Act, as Lanier was, the maximum period of probation allowed by law is that portion of the sentence not ordered to be served in confinement. See Burge v. State, 623 So.2d 450 (Ala. Crim. App. 1993), and Hatcher v. State, 547 So.2d 905 (Ala. Crim. App. 1989). In this case, the maximum period of probation allowed by law was 10 years, and once those 10 years lapsed the probationary period ended and Lanier's sentence expired. Because his probation was never revoked, although it was tolled for approximately 2 weeks (see note 2, supra), the 10-year maximum probationary term ended, and Lanier's sentence expired, in 2006, a decade before Lanier was resentenced. Therefore, the circuit court erred in concluding that Lanier's sentence had not expired before he was resentenced.
Having determined that Lanier's sentence had expired long before he was resentenced, the question before this Court is whether a trial court retains jurisdiction *308to correct an illegal sentence after that sentence has expired.3 Absent a posttrial motion under Rule 24, Ala. R. Crim. P., a trial court generally retains jurisdiction to modify a sentence for only 30 days after the sentence is imposed. See Ex parte Hitt, 778 So.2d 159, 162 (Ala. 2000). Under the Split Sentence Act, a trial court retains jurisdiction to suspend the confinement portion of a split sentence throughout that portion of the sentence. See § 15-18-8(g), Ala. Code 1975. The exception to these jurisdictional limitations is when the sentence imposed is illegal. It is well settled that an illegal sentence is a jurisdictional defect and both this Court and the Alabama Supreme Court have repeatedly recognized that an illegal sentence may be challenged, or noticed by this Court, at any time. See, e.g., Ex parte Jarrett, 89 So.3d 730, 732 (Ala. 2011) ; Ex parte Batey, 958 So.2d 339, 341 (Ala. 2006) ; McNeal v. State, 43 So.3d 628, 629 (Ala. Crim. App. 2008) ; and Ginn v. State, 894 So.2d 793, 796 (Ala. Crim. App. 2004). This Court has also recognized that " 'even after the defendant has begun to serve his sentence, the trial court is obligated to alter an invalid sentence [and] any increase in the sentence does not raise double jeopardy problems.' " Greenhill v. State, 746 So.2d 1064, 1072 (Ala. Crim. App. 1999) (quoting Love v. State, 681 So.2d 1108, 1109 (Ala. Crim. App. 1996) ).
However, it does not appear that this Court or the Alabama Supreme Court has ever been squarely presented with, or addressed, the issue whether a trial court retains jurisdiction to correct an illegal sentence after that sentence has expired,4 and it does not automatically follow from the jurisdictional nature of an illegal sentence that a trial court retains jurisdiction indefinitely to correct an illegal sentence. "[T]here must be a temporal limitation on a court's ability to resentence a defendant ... since criminal courts do not have perpetual jurisdiction over all persons who were once sentenced for criminal acts." People v. Williams, 14 N.Y.3d 198, 217, 899 N.Y.S.2d 76, 88, 925 N.E.2d 878, 890 (2010). That limitation logically falls at the expiration of a sentence. Although an illegal sentence may be corrected after the defendant has begun serving the sentence without double-jeopardy implications, resentencing a defendant after the expiration of a sentence, even to correct an illegal sentence, results in multiple punishments for the same offense.
"The Fifth Amendment's Double Jeopardy Clause protects against a second prosecution for the same offense after an acquittal, a second prosecution for the same offense after conviction, and against multiple punishments for the same offense." Woods v. State, 709 So.2d 1340, 1342 (Ala. Crim. App. 1997). "The clause applies to 'multiple punishment' because, if it did not apply to punishment, then the prohibition against 'multiple trials' would be meaningless; a court could achieve the same result as a second trial by simply resentencing a defendant after he has served all or part of an initial sentence."
*309United States v. Fogel, 829 F.2d 77, 88 (D.C. Cir. 1987). "[T]he primary purpose of the Double Jeopardy Clause [i]s to protect the integrity of a final judgment," United States v. Scott, 437 U.S. 82, 92, 98 S.Ct. 2187, 57 L.Ed.2d 65 (1978), and jeopardy attaches to a sentence when the defendant acquires "an expectation of finality in the original sentence." United States v. DiFrancesco, 449 U.S. 117, 139, 101 S.Ct. 426, 66 L.Ed.2d 328 (1980).
Several jurisdictions that have addressed the issue presented here have held that there is a jurisdictional limitation, founded on double-jeopardy principles, on a trial court's correcting an illegal sentence after the sentence has expired. In Commonwealth v. Selavka, 469 Mass. 502, 509, 14 N.E.3d 933, 941 (2014), the Supreme Judicial Court of Massachusetts recognized that "even an illegal sentence will, with the passage of time, acquire a finality that bars further punitive changes detrimental to the defendant" and the Court held that "the delayed correction of the defendant's initial sentence, in which he by then had a legitimate expectation of finality, violated double jeopardy and cannot stand." The New York Court of Appeals has similarly recognized:
"Even where a defendant's sentence is illegal, there is a legitimate expectation of finality once the initial sentence has been served and the direct appeal has been completed (or the time to appeal has expired) [so that] the sentences are beyond the court's authority and, ... although illegal under the Penal Law, ... the Double Jeopardy Clause prevents a court from modifying the sentence."
People v. Williams, supra, 14 N.Y.3d at 217-20, 899 N.Y.S.2d at 87-89, 925 N.E.2d at 890-91.
As Florida's Court of Appeal for the Second District succinctly stated: "Once a sentence has already been served, even if it is an illegal sentence or an invalid sentence, the trial court loses jurisdiction and violates the Double Jeopardy Clause by reasserting jurisdiction and resentencing the defendant to an increased sentence." Maybin v. State, 884 So.2d 1174, 1175 (Fla. Dist. Ct. App. 2004). See also State v. Holdcroft, 137 Ohio. St. 3d. 526, 527-33, 1 N.E.3d 382, 384-89 (2013) (holding that "when the entirety of a prison sanction has been served, the defendant's expectation in finality in his sentence becomes paramount, and his sentence for that crime may no longer be modified," even "when one of the sanctions originally imposed by the trial court is void"); March v. State, 109 N.M. 110, 111, 782 P.2d 82, 83 (1989) ("[T]he court has authority to correct an irregular sentence at any time prior to when defendant has served his full sentence."); Commonwealth v. Borrin, 12 A.3d 466, 472 (Pa. Sup. Ct. 2011) ("The double jeopardy clauses of the United States and Pennsylvania Constitutions prohibit a trial court from exercising its authority to correct a clerical error to increase a defendant's sentence when the defendant fully served the maximum term of his sentence, as stated in the sentencing order, and the direct appeal had been completed or the time for appeal has expired."), aff'd, 622 Pa. 422, 80 A.3d 1219 (2013) ; and State v. Houston, 795 N.W.2d 99 (Iowa Ct. App. 2010) (table) (unpublished disposition) ("In accord with double jeopardy principles, we conclude that a legitimate expectation of finality arises upon a defendant's completion of the original sentence. It follows that a proper limit on a court's ability to resentence a defendant to correct an illegal sentence should be prior to completion of the original sentence. Once the original sentence is fully served, the attachment of jeopardy ... preclude[s] the court from resentencing."). Cf., State v. Brown, 479 S.W.3d 200, 211 (Tenn. 2015) (interpreting a rule of procedure to prohibit correction *310of an illegal sentence after the sentence has expired in order to avoid unconstitutional results); and State v. Laird, 25 N.J. 298, 307, 135 A.2d 859, 864 (1957) (holding that a procedural rule permitting a trial court to correct an illegal sentence " 'at any time' " did not "authorize an enlargement of the punishment after the sentence imposed had been satisfied and the defendant discharged").
We agree with the above jurisdictions, and we hold that a trial court loses jurisdiction to correct an illegal sentence once that sentence expires and the direct appeal has been completed or the time to appeal has lapsed and that a trial court's correcting an illegal sentence after the expiration of that sentence violates principles of double jeopardy. Because Lanier's sentence for his 1996 robbery conviction expired in 2006, the circuit court lacked jurisdiction in 2016 to resentence him and doing so resulted in multiple punishments for the same offense in violation of double-jeopardy principles.
We recognize that Lanier's resentencing was the result of his filing a Rule 32 petition challenging his 1996 conviction and sentence.5 Lanier readily acknowledges that he challenged his 1996 conviction and sentence and that he did so because that conviction was subsequently used in 2011 to enhance five sentences he received upon application of the Habitual Felony Offender Act ("HFOA") for five counts of first-degree robbery. It is not uncommon for defendants to challenge a prior conviction in an attempt to eliminate it for use for sentence enhancement, and, under the doctrine of invited error, a defendant generally "will not be permitted to allege as error an action that was a natural consequence of his own actions." Bradley v. State, 925 So.2d 232, 241 (Ala. 2005). However, "the lack of subject-matter jurisdiction is a fundamental error depriving the court of the authority to render a valid decision," Ex parte V.S., 918 So.2d 908, 912-13 (Ala. 2005), and "a defendant cannot consent to waive a jurisdictional defect." Moore v. City of Leeds, 1 So.3d 145, 152 (Ala. Crim. App. 2008). Thus, although Lanier initiated the proceedings that led to his resentencing, he cannot be said to have consented to the circuit court resentencing him when the circuit court had no jurisdiction to do so.
We likewise recognize that Lanier's 25-year sentence has, essentially, been subsumed within the 5 sentences of life imprisonment without the possibility of parole he is currently serving for his 2011 convictions and has no effect on the length of his current incarceration. Nonetheless, we cannot ignore the fact that the circuit court lacked jurisdiction to resentence Lanier for his 1996 robbery conviction after the original sentence had expired and that Lanier is entitled to relief from that resentencing.6 Because the expiration of Lanier's *311sentence in 2006 rendered that sentence final and unmodifiable, the only available remedy at this point is reinstatement of Lanier's original, albeit illegal, sentence.
Based on the foregoing, the judgment of the circuit court summarily dismissing Lanier's Rule 32 petition is reversed, and this cause is remanded for the circuit court to grant Lanier's Rule 32 petition, to set aside his 25-year sentence, and to reinstate his original sentence. No return to remand need be filed.
REVERSED AND REMANDED.
Windom, P.J., and Welch and Burke, JJ., concur. Joiner, J., concurs in the result, with opinion.
JOINER, Judge, concurring in the result.
I concur in the result. I agree with the main opinion's ultimate conclusion that the circuit court did not have the authority to modify Samuel Lanier's sentence because that sentence had already expired and that resentencing Lanier violated double-jeopardy principles.
I also agree with the main opinion's holding that a circuit court does not have the authority to resentence a petitioner after the petitioner's sentence has expired "and the direct appeal has been completed or the time to appeal has lapsed." 270 So. 3d at 310. That proposition, however, is usually the case with any sentence--legal or illegal, completed or not yet completed. Generally, once a direct appeal has been completed or the time to appeal has lapsed, a circuit court does not have jurisdiction to modify a sentence--even an illegal one--absent the invocation of a procedural mechanism for doing so. See, e.g., Rule 26.12, Ala. R. Crim. P. In Waters v. State, 155 So.3d 311 (Ala. Crim. App. 2013), this Court stated:
"Rule 32, [Ala. R. Crim. P.,] which provides a procedural vehicle for a defendant to collaterally attack the proceedings that led to his conviction or sentence, authorizes the circuit court to, in essence, reopen the proceedings that led to the petitioner's conviction and sentence if the petitioner demonstrates he is entitled to relief. Our caselaw illustrates that when a Rule 32 petitioner obtains relief, the proceedings are reopened at the point necessary for the circuit court to address the particular problem in that case.
"For example, if a Rule 32 petitioner demonstrates that his sentence is illegal, the circuit court may then reopen the proceedings and resentence the petitioner. See, e.g., McMillian v. State, 934 So.2d 434 (Ala. Crim. App. 2005) (granting Rule 32 relief where the petitioner's sentence was improperly enhanced under the Habitual Felony Offender Act and instructing the circuit court to resentence the petitioner without the application of the Habitual Felony Offender Act). Additionally, if a Rule 32 petitioner shows that his conviction must be overturned then the conviction--and the corresponding sentence for that conviction-will be set aside and the proceedings will continue from that point--additional proceedings could include, *312for example, a new trial, a guilty plea, or the dismissal of the charges. See, e.g., Riley v. State, 892 So.2d 471 (Ala. Crim. App. 2004) (granting Rule 32 relief where the petitioner's guilty plea was involuntary and instructing the circuit court to set aside the petitioner's conviction and sentence)."
155 So.3d at 316-17.
Thus, the more precise question in this case is whether a petitioner may file a Rule 32 petition to obtain the "relief" of a harsher but legal sentence after the petitioner has completed his or her shorter but illegal sentence. I would hold that a petitioner may not do so. To hold otherwise would permit a petitioner to misuse the postconviction procedure provided in Rule 32.
Lanier's case is a clear example of a petitioner attempting to misuse Rule 32, Ala. R. Crim. P. Lanier's original claim, filed in a previous Rule 32 petition that resulted in the resentencing that is the basis of the instant appeal, was that his sentence for first-degree robbery was too short and was thus illegal. Lanier sought the "relief" of being resentenced to a longer sentence. This, of course, sounds like nonsense, and it is. But there is a strategy behind it.
As the main opinion recognizes, "[i]t is not uncommon for defendants to challenge a prior conviction in an attempt to eliminate it for use for sentence enhancement." 270 So. 3d at 310 (emphasis added). Here, Lanier's 1996 guilty-plea conviction was used to enhance his 2011 sentences, and Lanier ultimately wanted his 1996 conviction set aside. Presumably, however, no valid basis existed for challenging the 1996 conviction, and Lanier therefore challenged his 1996 sentence in an attempt to manufacture a problem with the guilty-plea conviction and have that conviction set aside.7 In other words, Lanier tried to do indirectly what he could not do directly.
In Hall v. State, 223 So.3d 977 (Ala. Crim. App. 2016), this Court held that a petitioner could not use Rule 32 to obtain the "relief" of having an additional fine imposed that the petitioner argued was mandatory. In my special concurrence in Hall, I stated:
"Hall has alleged that his sentence was 'illegal' because the circuit court failed to impose on him a $1,000 demand-reduction assessment [pursuant to § 13A-12-281, Ala. Code 1975 ]. To 'cure' this error, Hall contends that he is entitled to the postconviction 'relief' of being resentenced by the circuit court so that court could impose on him the demand-reduction assessment. In other words, Hall seeks to use Rule 32 to receive additional punishment from the circuit court. This is nonsense.
"It is not difficult to imagine other ridiculous scenarios. For example, imagine a Rule 32 petitioner who alleges that he was sentenced to 10 years' imprisonment for a conviction for a Class C felony. Imagine further that he claims that his 10-year sentence is 'illegal' because, he says, he has three prior felony offenses for purposes of the Habitual Felony Offender Act ('the HFOA'); that the State invoked the HFOA and properly proved all three prior felony offenses *313at his sentencing hearing; and that the circuit court, although acknowledging the existence of the three prior felony offenses, did not sentence him under the HFOA. Because, he says, his sentence is 'unauthorized' under the HFOA, and because '[m]atters concerning unauthorized sentences are jurisdictional,' the circuit court must 'grant' him postconviction 'relief' and resentence him to a harsher sentence under the HFOA--up to, and including, life imprisonment. This simply is not 'relief.'
"Like the writ of habeas corpus, Rule 32 exists as a possible key to 'unlock the prison doors,' see Barton v. City of Bessemer, 27 Ala. App. 413, 417-18, 173 So. 621, 625 (1936) (opinion on rehearing), rev'd on other grounds, 234 Ala. 20, 173 So. 626 (1937), not as a means to subject petitioners to additional or harsher punishment."
223 So.3d at 990-91.
Lanier's case is similar to the ridiculous scenario I envisioned in Hall. This type of action is not consistent with the stated purpose of Rule 32, Ala. R. Crim. P., which exists for a defendant "to secure appropriate relief" (emphasis added). It simply is not relief to use Rule 32 to obtain a longer sentence. In his prior Rule 32 petition, however, that is the "relief" Lanier obtained--a harsher sentence of 25 years instead of a 12-year sentence.8 Once Lanier got what he asked for, he filed another Rule 32 petition to undo what had been done at his request.9 Although I agree with the result of setting aside10 the 25-year "resentence," I would hold that Lanier should not have been permitted to proceed with his prior Rule 32 petition because it did not seek "relief."
In 2011, Lanier was convicted of five counts of first-degree robbery and was sentenced, as a habitual felony offender, to life imprisonment without the possibility of parole for each conviction. His 1996 robbery conviction was one of the convictions used to enhance his sentences. This Court affirmed Lanier's 2011 convictions and sentences, without an opinion. Lanier v. State (No. CR-10-0646), 120 So.3d 1241 (Ala. Crim. App. 2011) (table).
" 'As a practical matter, the running of the period of probation must be considered tolled when a warrant of arrest for violation of probation is issued by the court.' " Mumpfield v. State, 872 So.2d 205, 207 (Ala. Crim. App. 2003) (quoting Peoples v. State, 439 So.2d 774, 775 (Ala. Crim. App. 1983) ).
The parties do not dispute that Lanier's original sentence was illegal, and, for purposes of this opinion, we presume that it was.
This Court has addressed challenges to an illegal sentence brought after the sentences had expired. See Hall v. State, 223 So.3d 977 (Ala. Crim. App. 2016), and Watson v. State, 164 So.3d 622 (Ala. Crim. App. 2014). However, the issue whether a trial court has jurisdiction to correct an illegal sentence after the sentence has expired was not specifically presented in those cases and was not addressed by this Court. In addition, we have found no Alabama Supreme Court case that has addressed a challenge to an illegal sentence brought after the sentence had expired.
In the petition that led to his resentencing, Lanier alleged that he had pleaded guilty in 1996 pursuant to a plea agreement with the State; that he was sentenced in accordance with that plea agreement; that the sentence was illegal and resentencing was required to correct the illegality in the sentence; and that, once he was resentenced, he was entitled to withdraw his plea. See, e.g., Calloway v. State, 860 So.2d 900 (Ala. Crim. App. 2002) (opinion on return to remand and on second application for rehearing). The circuit court found that there was no plea agreement with the State and that Lanier had entered a "blind" plea, but it agreed with Lanier that the sentence was illegal.
It is unnecessary for this Court to remand this case to allow Lanier an opportunity to prove that the circuit court lacked jurisdiction to resentence him because the record conclusively establishes, and the State concedes, that Lanier was resentenced after his original sentence had expired, and the primary question before this Court is one of law, not fact, i.e., whether a trial court retains jurisdiction to correct an illegal sentence after that sentence has expired. "Therefore, as both this Court and the Alabama Supreme Court have done numerous times in the past when the record is clear on its face that a Rule 32 petitioner is entitled to relief, we grant that relief, rather than waste scarce judicial resources to remand for [Lanier] to present evidence that" is already in the record before this Court. Williams v. State, 104 So.3d 254, 265-66 n.5 (Ala. Crim. App. 2012). See also Lynch v. State, 229 So.3d 260, 268 n.3 (Ala. Crim. App. 2016).
Lanier's argument in the instant case was that the shorter and allegedly illegal sentence was a part of a bargained-for plea agreement. He sought a harsher sentence to then argue that the harsher sentence violated his plea agreement, rendering it involuntary. He then would have argued that the conviction should be set aside, and he would have done so in the hope that if it were set aside, the State would no longer have the evidence needed to convict him.
Lanier's efforts were unsuccessful in part because the circuit court found that no plea agreement existed.
The main opinion notes that it presumes that the 12-year sentence was illegal. Lanier pleaded guilty to first-degree robbery, see § 13A-8-41, Ala. Code 1975. First-degree robbery is a class A felony, which has a possible sentence of 10 years to life. His claim, however, was that he should have received a minimum sentence of 20 years under the enhancement for use of a firearm or a deadly weapon under former § 13A-5-6(a)(4), Ala. Code 1975. On the record before us, it is impossible to determine whether that enhancement should have applied. Thus, Lanier's sentence may have been legal.
Filing yet another Rule 32 petition was presumably the only procedural mechanism available to Lanier. Having obtained "relief" in the prior Rule 32 petition, Lanier, as the prevailing party, could not appeal from that decision. (Theoretically, the State could have appealed from it. But why would the State have done so?)
The main opinion directs the circuit court to reinstate the original sentence. In my opinion, setting aside the order that "resentenced" Lanier to 25 years is all that is required in this case. Arguably, because the original 12-year sentence has been completed, there is no sentence to reinstate. Regardless, once the resentencing order is set aside, it will have no effect on the original 12-year sentence.