OPINION
¶ 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,
¶ 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, 1 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. 2 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. 3 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. *444 The respondent judge stayed the underlying proceedings pending this special action.
¶ 4 Probation is a matter of “legislative grace.”
State v. Smith,
¶ 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.
4
Dominguez v. Meehan,
¶ 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,
¶ 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
*445
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,
¶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,
¶ 9 Plea agreements are contractual in nature and subject to contract interpretation.
See Santobello v. New York,
¶ 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,
¶ 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,
¶ 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,
¶ 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,
*447 ¶ 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.
Notes
. 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,
. 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,
