
    27 P.3d 799
    Frederick John COY, Petitioner, v. Hon. Richard S. FIELDS, Judge of the Superior Court of the State of Arizona, in and for the County of Pima, Respondent, and The State of Arizona, Real Party in Interest.
    No. 2 CA-SA 01-0018.
    Court of Appeals of Arizona, Division 2, Department A.
    May 31, 2001.
    As Corrected June 1 and June 12, 2001.
    
      Schaye & Associates, by Natman Schaye, Tucson, for Petitioner.
    Barbara LaWall, Pima County Attorney, by Elizabeth Tyszko, Tucson, for Real Party in Interest.
   OPINION

FLOREZ, Judge.

¶ 1 Petitioner Frederick John Coy seeks special action relief from the respondent judge’s order in the underlying criminal proceeding, granting the real party in interest State of Arizona’s motion to withdraw from the plea agreement, which motion was made after the plea was accepted and judgment entered. Because petitioner has raised a nonfrivolous double jeopardy claim and does not have an adequate remedy by appeal, Nalbandian v. Superior Court, 163 Ariz. 126, 786 P.2d 977 (App.1989), and because we find the respondent judge abused his discretion in permitting the state to withdraw from the plea agreement, we accept jurisdiction and grant relief. Ariz. R.P. Special Actions 1(a), 3,17B A.R.S.

¶ 2 Petitioner was indicted on one count of kidnapping, a class two felony, and two counts of sexual abuse, class five felonies. He entered into a plea agreement with the state whereby he pled guilty to one count of unlawful imprisonment, a class six felony. The relevant part of the plea agreement provided, “If probation is granted, the Defendant may be placed on lifetime probation pursuant to A.R.S. § 13-902(E).” The respondent judge accepted the plea, entered a judgment of conviction on the offense, suspended imposition of sentence, and placed petitioner on fifteen years’ probation.

¶ 3 Weeks later, petitioner filed a motion to modify the sentence pursuant to Rule 24.3, Ariz. R.Crim. P., 17 A.R.S. Petitioner requested that the respondent judge reduce the fifteen-year term of probation to three years, noting that the maximum term of probation for a class six felony is three years, see A.R.S. § 13-902(A)(4), and that § 13-902(E), which allows for the imposition of up to lifetime probation, is expressly limited to convictions of certain specified offenses, predominantly sex-based, of which unlawful imprisonment was not one. The state opposed the motion, agreeing that petitioner was not convicted of any of the offenses encompassed by § 13-902(E), but asserting that petitioner should be bound by the terms of the plea agreement, which it asked the respondent judge to enforce. Alternatively, the state requested that the respondent judge allow it to withdraw from the plea agreement. Petitioner replied that double jeopardy concerns would arise if the state were permitted to withdraw from the plea agreement and pursue its prosecution of the original charges. The respondent judge did not grant petitioner’s request and reduce his term of probation but, instead, “set aside [the] sentencing” entirely and granted the state’s request to set aside the plea agreement. Petitioner then filed a motion to dismiss the prosecution with prejudice, on the ground of double jeopardy; the respondent judge denied that motion. The respondent judge stayed the underlying proceedings pending this special action.

¶ 4 Probation is a matter of “legislative grace.” State v. Smith, 112 Ariz. 416, 419, 542 P.2d 1115, 1118 (1975). A trial court has no jurisdiction to impose probationary terms except as provided for by the legislature. See State v. Jordan, 120 Ariz. 97, 584 P.2d 561 (1978); see also State v. Vargas-Burgos, 162 Ariz. 325, 783 P.2d 264 (App.1989) (trial court has no subject matter juris diction to impose sentence except as mandated by statute). Because the fifteen-year probationary term was not statutorily authorized for conviction of unlawful imprisonment, the respondent judge was obligated either to reduce the probationary term to three years or less, which would be consistent with the plea agreement, or to do as it did and set aside the sentencing. See State v. Bouchier, 159 Ariz. 346, 767 P.2d 233 (App.1989) (probationary term exceeding that permitted by statute is fundamental error, equivalent to illegal prison sentence).

¶ 5 We next address whether the respondent judge should have permitted the state to withdraw from the plea. Rule 17.5, Ariz. R.Crim. P., 16A A.R.S., gives a trial court discretion to allow either party to withdraw from a plea and to reinstate the charges in effect before the plea agreement was negotiated to correct a manifest injustice. But, once the court accepts the plea, the state generally may not withdraw from the agreement because jeopardy has attached. Dominguez v. Meehan, 140 Ariz. 329, 681 P.2d 912 (App.1983), approved, 140 Ariz. 328, 681 P.2d 911 (1984). An exception exists when a defendant breaches his or her obligations under the agreement. Courts have found the breach constitutes a waiver of his or her double jeopardy protections, and in such cases the government has been permitted to withdraw from the agreement and reinstate the original charges without offending the Double Jeopardy Clause. See Rick-etts v. Adamson, 483 U.S. 1, 107 S.Ct. 2680, 97 L.Ed.2d 1 (1987) (state permitted to withdraw from agreement when defendant refused to testify at codefendant’s trial as promised); United States v. Reardon, 787 F.2d 512 (10th Cir.1986) (defendant breached agreement when he failed to give full accounting of his drug activities to authorities as required by plea agreement; state permitted to withdraw from plea); Dutton v. State, 970 P.2d 925 (Alaska Ct.App.1999) (defendant relinquished his double jeopardy rights by voluntarily breaching agreement and state could withdraw, despite no express provision regarding waiver of double jeopardy rights in agreement).

¶ 6 Thus, the pivotal question here is whether petitioner breached the agreement. The state argues that petitioner “violated” and “breach[ed]” the agreement because he agreed to an extended probationary term when he accepted the agreement, yet subsequently challenged the enforceability of that provision. We reject the state’s argument. That petitioner had earlier agreed to the possibility of an extended probationary term did not preclude him from utilizing Rule 24.3 for its express purpose — -to alert the respondent judge that he had imposed an illegal term of probation. See United States v. Sandoval-Lopez, 122 F.3d 797 (9th Cir.1997) (although defendants had pled guilty to certain crimes pursuant to plea agreement, nothing in agreement prevented them from later challenging those convictions through federal habeas corpus actions; doing so did not constitute breach); see also United States v. Barron, 172 F.3d 1153 (9th Cir.1999) (defendant did not breach plea agreement by successfully challenging legal sufficiency of convictions to which he had pled guilty where he did not challenge agreement itself).

¶ 7 Many of the cases in this area involve plea agreements that provide for an illegally lenient sentence. In such a situation, courts generally either vacate the plea or give the defendant the option of withdrawing from the plea or agreeing to a legal sentence in excess of the agreement’s provisions. See, e.g., People v. Jackson, 121 Cal.App.3d 862, 176 Cal.Rptr. 166 (1981) (noting that trial court must allow a defendant to withdraw his plea if plea bargain cannot be effectuated); People v. Hare, 315 Ill.App.3d 606, 248 Ill.Dec. 587, 734 N.E.2d 515 (2000) (trial court properly vacated illegal sentence and did not err in refusing to reform agreement); People v. Hipp, 197 A.D.2d 590, 602 N.Y.S.2d 428 (1993) (vacating illegal probationary term but remanding so defendant could withdraw plea or accept lawful sentence). In Chae v. People, 780 P.2d 481 (Colo.1989), the plea agreement provided that the imprisonment would be suspended, which was not permitted under Colorado law. The plea was vacated in recognition of the fundamental constitutional requirement that a valid guilty plea be entered knowingly, intelligently, and voluntarily. Id.; see Boykin v. Alabama, 395 U.S. 238, 89 S.Ct. 1709, 23 L.Ed.2d 274 (1969).

¶8 No such constitutional considerations arise here, however, where the stipulated range of probation is Ulegal because it imper-missibly authorized a probationary term exceeding the maximum allowed by law. The state nonetheless argues that the respondent judge’s act of setting aside the plea agreement was justified under contract principles, contending that it dropped the sexually based charges in the indictment and allowed petitioner to plead to a non-sex-based crime as a concession that would allow petitioner to keep his job; in exchange, petitioner agreed to be subject to the extended probation allowed under § 13-902(E), which the state felt was required for the protection of the public. The state thus asserts that the avaüability of extensive probation was a material provision of the plea agreement and that the nullification of the provision has frustrated the purpose of the plea agreement, warranting its rescission. See United States v. Bunner, 134 F.3d 1000 (10th Cir.1998) (defendant’s successful challenge to plea-based conviction in habeas corpus action repudiated plea agreement, discharging government’s obligations under the agreement and enabling reinstatement of original charges).

¶ 9 Plea agreements are contractual in nature and subject to contract interpretation. See Santobello v. New York, 404 U.S. 257, 92 S.Ct. 495, 30 L.Ed.2d 427 (1971); United States v. Lewis, 979 F.2d 1372 (9th Cir.1992); Mejia v. Irwin, 195 Ariz. 270, 987 P.2d 756 (App.1999). But we are not always obligated to apply a contract analysis to plea agreements because contract law may not provide a sufficient analogy. United States v. Carrillo, 709 F.2d 35 (9th Cir.1983); State v. Taylor, 196 Ariz. 549, 2 P.3d 108 (App.1999). Although we find well taken the state’s concern for protecting the public, we conclude rescission is inappropriate here, even if we apply principles of contract law.

¶ 10 First, we do not agree with the state that nullifying the § 13-902(E) provision materially alters the plea agreement, which provided only for the possibility of up to lifetime probation. The agreement also implicitly contemplated that the respondent judge could, in the exercise of his discretion, impose probation or imprisonment within the legal range for a class six felony. Had such a probationary term or sentence been imposed, the state, having agreed to that result, could not complain that the court did not impose a longer term of probation. In imposing the fifteen-year probationary term, the respondent judge breached the law, not the plea agreement.

¶ 11 Moreover, although we are not aware of any Arizona case directly on point, we find State v. Patience, 944 P.2d 381 (Utah App.1997), analogous and instructive. There, the defendant, charged with three counts of forgery, had entered into a plea agreement with the state whereby she pled guilty to “three counts of attempted forgery, third degree felonies.” Id. at 383. The trial court imposed consecutive prison terms for the “three third degree felonies.” Id. at 384. But, unbeknownst to the court, the prosecutor, and the defendant, the Utah legislature had reduced attempted forgery to a misdemeanor before the parties had negotiated and entered into the plea agreement. Once discovered, the defendant appealed her sentence on the ground that it was illegal. The state sought to rescind the plea agreement on the ground of “mutual mistake of material fact” and asked that the original charges be reinstated. Id. at 385.

¶ 12 In refusing the state’s request to rescind the plea agreement, the Patience court noted that, as here, the defendant had neither breached the agreement nor withdrawn from nor modified the agreement, conditions which generally would have permitted the state to withdraw. Moreover, the court held that rescission was inappropriate even under a contract law analysis:

[A] party may not rescind an agreement based on mutual mistake where that party bears the risk of mistake. See 17A Am. Jur.2d Contracts § 215 (1991). In this case, we conclude the State bore the risk of the mistake as to the law in effect at the time the parties entered into the plea agreement. The State is generally in the better position to know the correct law ... and the State must be deemed to know the law it is enforcing. Indeed, it is the State’s law, duly enacted by its legislative branch, that is in issue. The State must be charged with knowledge of its own legislative enactments and, in that sense, cannot be said to have been mistaken about the governing statute in effect when it agreed to the plea arrangement....
... Under these circumstances, we refuse to relieve the State of what it now considers a bad bargain where the plea agreement was the result of uninduced mistake as to the current provisions of Utah statute.
We conclude that the State may not rescind the plea agreement in this case based on mutual mistake.

Patience, 944 P.2d at 387-88. The court thus remanded the case to the trial court for resentencing on the misdemeanors. See also Osborne v. State, 304 Md. 323, 499 A.2d 170, 178 (1985) (state not permitted to withdraw from plea when it made “bad bargain” due in part to its ignorance of applicable state law). But see Rojas v. State, 52 Md.App. 440, 450 A.2d 490 (1982) (plea agreement vacated when severance of unenforceable, material term would not adequately protect public).

¶ 13 We, too, hold the state accountable for knowing Arizona law when it negotiates, drafts, and enters into plea agreements. We agree with the court in Patience that the state bears the risk when, as here, a sentencing or probation provision in one of its plea agreements proves to be illegal and unenforceable. Of course, had there been an allegation and finding below that petitioner had negotiated or entered into the plea agreement in bad faith, never intending to comply with the terms of the agreement or knowing that a probationary term of more than three years was impossible, the state’s withdrawal from the plea would have been appropriate. See Taylor (defendants must deal in good faith before they can attempt to claim benefits of contract law in plea agreement disputes). Because there was no valid ground on which the state was entitled to withdraw from the plea agreement, the respondent judge abused his discretion in setting the plea agreement aside, and we vacate that order. See State v. Chapple, 135 Ariz. 281, 660 P.2d 1208 (1983) (equating abuse of discretion with legally incorrect ruling). Accordingly, petitioner’s double jeopardy claim is moot.

¶ 14 For relief, petitioner asks us to order the respondent judge to “reinstate [his] conviction and impose a lawful sentence, including a term of probation not to exceed three years.” Because we have vacated the order setting aside the plea agreement, petitioner’s judgment of conviction needs no reinstatement. As for the sentence, petitioner essentially asks us to order the respondent judge to strike the illegal portion of the probationary term originally imposed. However, the plea agreement did not require the granting of probation but left that decision to the discretion of the respondent judge. Because we cannot say that the respondent judge necessarily would have suspended imposition of sentence and granted probation had he known the probationary term could be no longer than three years, see State v. Ojeda, 159 Ariz. 560, 769 P.2d 1006 (1989), we remand for sentencing anew. This will not be a “resentencing” because the original “sentence” was illegal and void; consequently, no concerns under Rule 26.14, Ariz. R.Crim. P., 17 A.R.S., can arise. See State v. Carbajal, 184 Ariz. 117, 907 P.2d 503 (App.1995).

¶ 15 We therefore vacate the respondent judge’s order setting aside the plea agreement and remand this matter to the Superior Court for further proceedings consistent with this opinion.

BRAMMER, P.J., and PELANDER, J., concurring. 
      
      . Although the limited record before us does not contain the minute entry from the change-of-plea hearing, we can infer from the record and the pleadings before us that the respondent judge accepted the negotiated plea.
     
      
      . The imposition of probation is technically not a "sentence” but a feature of the suspension of imposition of a sentence. See State v. Barksdale, 143 Ariz. 465, 694 P.2d 295 (App.1984).
     
      
      . Section 13-902(E), A.R.S., does provide for the possibility of up to lifetime probation for conviction of sexual abuse, a crime for which petitioner was twice indicted.
     
      
      . The plea agreement in this case contained a provision outlining specific circumstances under which the state would be entitled to withdraw from the plea and petitioner would waive any double jeopardy claims. None of these circumstances arose here. See Dominguez v. Meehan, 140 Ariz. 329, 681 P.2d 912 (App.1983), approved, 140 Ariz. 328, 681 P.2d 911 (1984) (defendant’s waiver of double jeopardy strictly limited to state's withdrawal for reasons outlined in plea agreement).
     