
140 Ariz. 329 (1983)
681 P.2d 912
Apolonio DOMINGUEZ, Petitioner,
v.
The Honorable Thomas MEEHAN, Judge of the Superior Court, In and For the County of Pima, State of Arizona, Respondent, and The STATE of Arizona, Real Party in Interest.
No. 2 CA-CIV 4834.
Court of Appeals of Arizona, Division 2.
July 15, 1983.
Rehearing Denied September 28, 1983.
Review Granted November 15, 1983.
Frederic J. Dardis, Pima County Public Defender by Hector Estrada, Tucson, for petitioner.
Stephen D. Neely, Pima County Atty., by Barbara LaWall, Deputy County Atty., Tucson, for real party in interest.
*330 OPINION
BIRDSALL, Judge.
The petitioner is charged in the Superior Court in Pima County with two counts of endangerment and one count of aggravated assault. All three crimes are alleged to be of a dangerous nature.
On January 4, 1983, the petitioner and the state, the real party in interest, entered into a written plea agreement which was presented to the respondent Judge and accepted. The court set sentencing for March 3. On that date the trial court rejected the plea agreement, finding that it was not in the interests of justice to accept it. The court also set the case for trial. Subsequently, the petitioner moved the trial court to impose sentence in accordance with the plea agreement, and the court refused.
On March 28 a petition for special action was filed in this court. The petitioner sought to have us direct the trial court to proceed with the sentencing pursuant to the plea agreement. After hearing, this court entered the following order on April 12:
"It appearing that the trial court accepted the plea and, it appearing that the trial court abused its discretion by setting aside the plea and judgment of guilt without giving the defendant an opportunity to withdraw his plea, see Smith v. Superior Court, etc., 130 Ariz. 210, 635 P.2d 498 (1981), the order of the trial court dated March 3, 1983 is vacated and set aside and the trial court is ORDERED to proceed as set forth in Smith, supra."
In Smith, supra, the supreme court applied Rule 17.4, Arizona Rules of Criminal Procedure, 17 A.R.S., holding that the trial judge, after having accepted the guilty plea, was not bound by the terms of the plea agreement regarding sentence, but, rather, could refuse to sentence pursuant to the agreement and offer the defendant the opportunity to withdraw his plea. Rule 17.4, Arizona Rules of Criminal Procedure, 17 A.R.S., contains comprehensive provisions regarding plea negotiations and agreements. The subparagraphs leading to the result in Smith are:
"d. Acceptance of Plea. After making such determinations, the court shall either accept or reject the tendered negotiated plea. The court shall not be bound by any provision in the plea agreement regarding the sentence or the term and conditions of probation to be imposed, if, after accepting the agreement and reviewing a presentence report, it rejects the provision as inappropriate.
e. Rejection of Plea. If an agreement or any provision thereof is rejected by the court, it shall give the defendant an opportunity to withdraw his plea, advising him that if he permits his plea to stand, the disposition of the case may be less favorable to him than that contemplated by the agreement."
The next hearing in the trial court was on May 10. The state filed a notice of withdrawal from the plea agreement and, after hearing argument from both parties, the court permitted the state to withdraw, vacated the sentencing hearing and again ordered the case set for trial. Subsequently, the trial court refused the petitioners "motion for specific performance" of the plea agreement. Thereupon this present special action proceeding was commenced, the petitioner again seeking to have the trial court directed to proceed with the plea agreement. We have accepted jurisdiction because the questions presented concern not only the criminal rule but also the form of plea agreement which we understand is almost always used in Pima County. We deny any relief since we find the respondent judge did not abuse his discretion or exceed his jurisdiction.
The state persuaded the trial court that it was also entitled to withdraw from the agreement. It relied both upon State v. Superior Court, 125 Ariz. 575, 611 P.2d 928 (1980) and language in the plea agreement itself.
In State v. Superior Court, ibid, the trial judge accepted the plea, ordered and received a presentence report. The resulting *331 sentence was less than that provided for in the plea agreement, and the state petitioned for special action relief.
In State v. Superior Court our supreme court said:
"The rule does not specifically provide that the State may also withdraw from the plea agreement previously entered into if the court rejects the terms of the plea agreement. We believe, however, it is implicit in the rule that the State, if it is to bargain freely and on equal terms with the defendant, must also be allowed to timely withdraw from a plea agreement when it is apparent that the court does not wish to abide by its terms."
Both State v. Superior Court, ibid, and Smith, supra, specifically recognize that the acceptance of a guilty plea constitutes jeopardy. See also Lombrano v. Superior Court, 124 Ariz. 525, 606 P.2d 15 (1980) and Williams v. Superior Court, 130 Ariz. 209, 635 P.2d 497 (1981).
These cases teach: 1) so long as the trial court reserves the acceptance of a plea it may reject it if it finds the disposition available unacceptable. It may also reject the plea for other reasons, for example, if it finds no factual basis for the plea. No jeopardy has attached. Or 2), if the trial court accepts the plea it is nevertheless not bound by the sentencing provisions in the agreement, and it may reject them. In this event the defendant must be given an opportunity to withdraw his plea. The state cannot withdraw, however, since jeopardy has attached. The withdrawal of the plea by the defendant voids the agreement, and the parties are returned to their original positions.[1] On the other hand, if the defendant elects not to withdraw his plea then the judge may sentence within the legal range, and the disposition may be less favorable to the defendant.
Disregarding for the moment the other provisions in the plea agreement, the instant case falls under (2) above. The judge has accepted the plea. Jeopardy has attached. The defendant has been given the opportunity to withdraw his plea and has declined. The trial judge could have proceeded with sentencing. Instead the state was permitted to withdraw and the plea was set aside without the defendant's consent. Except for the provisions in the plea agreement, a subsequent trial would constitute double jeopardy.
Contained in the instant plea agreement were the following significant provisions:
"4. The parties agree that the Court shall accept this plea agreement at the time of the Defendant's plea. The State's participation in this plea agreement is conditional upon the Court's acceptance of the plea at the change of plea hearing. If, after accepting the plea, the Court concludes that any of the terms or provisions of this agreement are unacceptable, both parties shall be given the opportunity to withdraw from this agreement, or the Court can reject the agreement.... Should the Court reject this agreement, or the State withdraw from the agreement, the Defendant hereby waives all claims of double jeopardy."[2]
Thus, by the very terms of the agreement the appellant has waived any double jeopardy claim if the court rejects the agreement or the state withdraws. Either the court's rejection or the state's withdrawal must be for reasons contained in the agreement, one of which is the court's conclusion that "terms or provisions of this agreement are unacceptable." This would include terms or provisions regarding sentence.
*332 Just as the appellant may waive other constitutional rights he may waive double jeopardy. Lombrano, supra. And see United States v. Jerry, 487 F.2d 600, (3d Cir.1973); United States v. Broussard, 645 F.2d 504 (5th Cir.1981); United States v. Gaertner, 583 F.2d 308 (7th Cir.1978), cert. denied, 440 U.S. 918, 99 S.Ct. 1238, 59 L.Ed.2d 469 (1979). Double jeopardy is waived by a plea of guilty. It is a personal defense which must be affirmatively plead. Kistner v. United States, 332 F.2d 978 (8th Cir.1964); Cox v. Crouse, 376 F.2d 824 (10th Cir.1967), cert. denied, 389 U.S. 865, 88 S.Ct. 128, 19 L.Ed.2d 136 (1967); Smith v. United States, 359 F.2d 481 (8th Cir.1966); United States v. Hoyland, 264 F.2d 346 (7th Cir.1959), cert. denied, 361 U.S. 845, 80 S.Ct. 98, 4 L.Ed.2d 83 (1959).
The foresight and ingenuity of the draftsman of the printed plea agreement made it possible for the respondent trial judge to exercise his discretion after careful consideration of all the facts available at what would have been the time of sentencing. Otherwise the trial judge might have been held to a hasty decision made during the change of plea before all the necessary information became available. As the Court of Appeals of N.Y. observed in People v. Farrar, 52 N.Y.2d 302, 437 N.Y.S.2d 961, 419 N.E.2d 864 (1981):
"The determination of an appropriate sentence requires the exercise of discretion after due consideration given to, among other things, the crime charged, the particular circumstances of the individual before the court and the purpose of a penal sanction, i.e., societal protection, rehabilitation and deterrence (see People v. McConnell, 49 N.Y.2d 340, 346, 425 N.Y.S.2d 794 [, 402 N.E.2d 133]; Penal Law, § 1.05, subd. 5). The law and strong public policy of this State mandate that the court, detached from outside pressures often brought to bear on the prosecution and defense, make that determination. Quite simply, the court must perform the delicate balancing necessary to accommodate the public and private interests represented in the criminal process.
Contrary to the People's argument, the court cannot be deemed to have finally exercised its discretion at the time that the plea, with the proposed sentence, is accepted. While the court legitimately may indicate that a proposed sentence is fair and acceptable, the necessary exercise of discretion cannot be fixed immutably at the time of the plea, for the decision requires information that may be unavailable then .... the sentencing function rests primarily with the Judge, whose ultimate obligation is to impose an appropriate sentence and who must exercise his or her responsibility at the time of sentencing in the light of information obtained from the presentence report or other source (id., at pp. 238-240, 360 N.Y.S.2d 623, 318 N.E.2d 784). Any other rule would negate the distinctions between the court's role in sentencing and accepting a plea and ignore the procedures designed to ensure that an appropriate sanction be imposed. Thus, a sentence negotiated prior to the plea, and in most cases prior to receipt of a presentence report, does not automatically become the sentence of the court. Just as the court must be free to impose a more severe sentence when warranted, the plea and sentence process must leave the court leeway to consider a lesser penalty when the facts and justice so require. No less can be accepted if the integrity of the criminal justice system is to be maintained."
Relief denied.
HOWARD, C.J., and HATHAWAY, J., concur.
NOTES
[1]  Except under Rule 17.4(g), Arizona Rules of Criminal Procedure, 17 A.R.S., if a presentence report has been submitted, the judge shall disqualify himself upon request of the defendant.
[2]  The opinion in State v. Superior Court, supra, sets out portions of that plea agreement which include a provision giving both the state and the defendant the right to withdraw from the plea agreement if the court concludes the sentencing provisions are inappropriate. Although the opinion quotes the provision verbatim the court does not discuss, much less rely upon, the provision.
