
608 N.W.2d 853 (2000)
In the Matter of Charles Randal ASHMAN.
No. C8-98-2078.
Supreme Court of Minnesota.
March 16, 2000.
*854 Michael Hatch, Attorney General of Minnesota, St. Paul, Amy Klobuchar, Hennepin County Attorney, Gayle C. Hendley, Assistant Hennepin County Attorney, Minneapolis, for respondent.
William E. McGee, Fourth District Public Defender, Peter W. Gorman, Assistant Public Defender, Hennepin County Public Defender's Office, amicus curiae, Minneapolis.
Heard, considered and decided by the court en banc.

OPINION
STRINGER, Justice.
Appellant Charles Randal Ashman has a history of criminal sexual conduct beginning in 1981 and continuing in 1982 and 1985. In 1991 he was again arrested and was charged with criminal sexual conduct in the second-degree in violation of Minn. Stat. § 609.343 (1990) and criminal sexual conduct in the fourth-degree in violation of Minn.Stat. § 609.345 (1990). Because of his three previous convictions he was subject to referral by the court for civil commitment. See Minn.Stat. § 609.1351 (1990).[1] In exchange for the county attorney's agreement to drop the second-degree criminal sexual conduct charge carrying a mandatory 37 year sentence and the further condition, as expressed by appellant's attorney, "that the court at the time of sentencing would not refer this matter for the possibility of judicial commitment," appellant pled guilty to the fourth-degree criminal sexual conduct charge. Seven years later, but before completing his sentence, the Department of Corrections (DOC) petitioned for appellant's civil commitment pursuant to Minn.Stat. *855 § 253B.185, subd. 1 (1998), as a sexual psychopathic personality and a sexually dangerous person. Appellant challenged the commitment asserting that it violated the terms of his 1991 plea agreement. The district court granted the DOC's petition for judicial commitment finding that the terms of the plea agreement were satisfied, but upon appellant's renewed motion the district court reversed itself. The court dismissed the DOC's petition based on testimony provided by the defense attorney representing appellant in 1991 that at the time of the 1991 plea and sentencing the parties intended that appellant would not be subject to civil commitment at any time unless appellant reoffended. The court of appeals reversed the district court holding that the county attorney had no authority to bind the DOC to such an agreement. See In re Ashman, 1999 WL 262147 (Minn.App. May 4, 1999). We affirm the court of appeals but on different grounds.
Appellant's history of criminal sexual conduct began in 1981 when he sexually assaulted a 14-year-old girl in Crookston, Minnesota. He pled guilty to third-degree criminal sexual conduct on January 4, 1982 and was sentenced to 21 months incarceration, which was suspended conditioned on eight months treatment at Northwest Regional Correctional Center. The day after entering his plea he attempted to sexually assault a woman at knifepoint in East Grand Forks, Minnesota. For that offense he pled guilty to attempted first-degree criminal sexual conduct and was sentenced to 54 months, later reduced to 36 months. Four months after his discharge on January 5, 1985, in Crookston he again sexually assaulted a woman. He pled guilty to third-degree criminal sexual conduct and was sentenced in an upward durational departure to 82 months but was paroled on January 27, 1990. He committed the offense that is now before this court sixteen months later, on May 19, 1991, when he sexually assaulted a 13-year-old girl while on a fishing trip and was charged with second- and fourth-degree sexual conduct. Because of appellant's previous convictions for criminal sexual conduct, for his 1991 offense he was subject to both enhanced sentencing as a pattern sex offender and referral by the court for civil commitment as a psychopathic personality. See Minn. Stat. § 609.1351.
During a Rasmussen hearing on November 8, 1991 the parties reached a plea agreement: appellant would plead guilty to criminal sexual conduct in the fourth-degree, accept the maximum ten year sentence and cooperate in another police investigation and, in exchange, the state would dismiss the more serious charge of criminal sexual conduct in the second degree, carrying a maximum 37 year sentence. The agreement also included a provision relating to appellant being subject to a civil commitment referral and it is the terms of this aspect of the plea agreement that is the subject of this appeal.
Because appellant's attorney was concerned for appellant's safety as a result of his cooperation in another criminal investigation, she requested that the plea be sealed and that additional conditions of the agreement relating to his cooperation be kept out of the record. During the hearing on the plea agreement the prosecutor referred to the additional conditions: "There are additional conditions of the plea negotiation which counsel has requested not be placed on the record. Those matters will be put into writing and will become part of the plea agreement." The additional conditions were never put into the record or in writing.
The petition to enter a plea of guilty, which was drafted by appellant's attorney and signed by appellant, provides a skeletal explanation of the terms of the agreement: "plea to lesser (Ct.II) dismiss Ct. I. 10 year sentence under Minn.Stat. § 609.1352.[2] Court will not refer for judicial commitment." In presenting the *856 terms of the plea agreement to the court, appellant's attorney explained "it was my understanding that we all agree that at this time the agreement would be to sentence my client pursuant to 609.1352 and that there would not be under 609.1351, that the Court at the time of sentencing would not refer this matter for the possibility of judicial commitment." (emphasis added.) The county attorney and the appellant specifically affirmed that those were the terms of the plea agreement. The court then stated that its acceptance of the plea agreement was conditioned upon its review of the terms of the agreement that were not in writing nor discussed in court. The court did not refer appellant for civil commitment at sentencing.
Appellant's supervised release date from prison was May 30, 1998. Pursuant to Minn.Stat. § 253B.185, subd. 1, on May 18, the DOC civil commitment referral coordinator prepared and the county attorney approved for good cause a petition[3] to commit appellant as a sexual psychopathic personality and a sexually dangerous person.[4] The petition was filed citing appellant's numerous incidents of criminal sexual conduct prior to his incarceration, the conduct for which he was incarcerated and non-sexual altercations occurring while he was in prison.[5] The petition noted that appellant did not participate in sex offender or chemical dependency treatment programs and concluded that appellant was a threat to others and was likely to reoffend: "[Appellant] appears to be at grave risk for re-offense. He continues to use threats and assaultive behavior. Despite opportunities and exposure to sex offender treatment, he has refused to participate, denies his offense, and lacks any sense of remorse."
Appellant moved to dismiss the petition asserting that it violated his plea agreement *857 relating to referral for judicial commitment. In a hearing on May 29, 1998 appellant testified that his understanding of the agreement was "that I could not get more than ten years in prison and * * * [t]hat no civil commitment could be filed against me at any time unless I would commit a similar crime." Appellant also testified that at the 1991 plea hearing he was concerned about civil commitment but he was also concerned about the possibility of 37 years in prison for a conviction of second-degree criminal sexual conduct, and this factored into his decision "[p]robably the same amount as the commitment."
On June 17 the district court issued an order denying appellant's motion to dismiss the commitment petition, ruling that the plea agreement specifically provided that the court would not refer appellant for civil commitment at the time of sentencing and since the court did not do so, the terms of the plea agreement had been satisfied. The court also noted that there was no evidence that the agreement was intended to bar commitment proceedings at the conclusion of appellant's sentence.
Appellant filed a new motion to dismiss on September 30, 1998, raising additional defenses of lack of subject matter jurisdiction and res judicata. This motion was supported by affidavit testimony of appellant's attorney in the 1991 plea agreement proceeding, who had been unavailable for the proceeding in May, that her understanding of the plea agreement was that "the State would never move for judicial commitment based on this offense or on [appellant's] prior convictions." In the hearing on appellant's renewed petition appellant's attorney clarified that she meant by that statement that while appellant was under the control of the Commissioner of Corrections, neither the county attorney nor the judge would seek civil commitment-thus his guilty plea could not be the basis for civil commitment absent future criminal sexual misconduct. She also stated:
[Appellant] would never have taken the agreement if it only meant that the judge would not at time of sentencing move for judicial commitment[.] * * * The reason that he chose to plead guilty was because he was assured that there would be no judicial commitment based on his plea of guilty in that case.
When questioned why the plea transcript referenced only referral by the court at sentencing, appellant's attorney responded that her handwritten note in the petition was shorthand for the agreement that the prosecutor would not move for judicial commitment and the judge would not judicially commit. She also explained that her understanding of the civil commitment statutes at the time was that either the court would make a determination whether civil commitment was appropriate and forward the determination to the county attorney or the county attorney would act as the petitioning party. Since the court approved the plea agreement and the county attorney agreed not to commit, she thought that "all the bases were covered."
The court reviewed its earlier dismissal of appellant's motion, reversed itself and granted the motion ruling that it "now has serious reservations as to whether the prosecution has fulfilled its part of the plea agreement" based on the testimony of appellant's attorney that in 1991 the parties to the plea agreement intended that "there would never be a civil commitment of [appellant] based on his conduct up to the time of the plea negotiation. It was intended that civil commitment would only be pursued in the event that [appellant] engaged in further sexual misconduct at some later time." The court noted that while in prison appellant on several occasions told prison officials that his plea agreement barred civil commitment and that "it is not clear what effort was made by prison officials who heard these assertions to explore the accuracy of [appellant's] statements in a timely manner." The court concluded that since appellant *858 had not engaged in any sexual misconduct since 1991 and since in close cases plea agreements must be construed in favor of defendants, justice to the appellant required dismissal of the petition.
The court of appeals reversed applying basic contract law. The court reasoned that because the DOC, the petitioner, was not a party to the 1991 plea agreement and the county attorney has no authority to bind the DOC in a civil commitment proceeding, the DOC was not bound by the plea agreement. See In re Ashman, 1999 WL 262147 at 2-4 (Minn.App. May 4, 1999). The court also held that because the county attorney's decision to accept a plea in a criminal proceeding involves different considerations than a determination that good cause exists to file a civil petition for commitment, the 1991 plea did not preclude a determination of good cause for the civil commitment petition in 1998. See id. at 4. The court of appeals also noted "we are not convinced that the parties intended anything more than that the sentencing court would not forward a recommendation for commitment under Minn. Stat. § 609.1351 (1990), as indicated in the plea petition and in the transcript of the plea proceeding." Id.
In Minnesota plea agreements have been analogized to contracts and principles of contract law are applied to determine their terms. See State v. Spaeth, 552 N.W.2d 187, 194 (Minn.1996). Whether there is ambiguity in a contract is a legal determination. See Republic Nat'l Life Ins. Co. v. Lorraine Realty Corp., 279 N.W.2d 349, 354 (Minn.1979). Thus, in our determination whether the district court erred in holding that there was an ambiguity in the plea agreement we are not bound by the district court's conclusion. See Lamb Plumbing & Heating Co. v. Kraus-Anderson of Minneapolis, Inc., 296 N.W.2d 859, 862 (Minn.1980). Where a defendant's liberty interests are implicated in a criminal proceeding, as here, we generally "temper contract principles with `safeguards to insure the defendant [receives] what is reasonably due in the circumstances,'" Spaeth, 552 N.W.2d at 194 (quoting Santobello v. New York, 404 U.S. 257, 262, 92 S.Ct. 495, 30 L.Ed.2d 427 (1971)), and in close cases, plea agreements should be construed to favor defendants. See State v. Witte, 308 Minn. 214, 216, 245 N.W.2d 438, 439 (1976). But where the plea agreement is not susceptible to more than one construction, as a matter of law there is no ambiguity. See Republic Nat'l, 279 N.W.2d 349 at 354.
Applying these principles to the issue here, we believe the terms of the plea agreement were clearly and unequivocally expressed when on November 8, 1991 appellant's attorney presented them to the district court, the county attorney and appellant acknowledged them, and the district court approved them. In the plea hearing transcript appellant's attorney recited that the plea agreement was that "at the time of sentencing" appellant would not be referred for civil commitment. As the plea agreement was clearly expressed by appellant's attorney and confirmed by appellant to represent the plea, the fact that appellant, while in prison, claimed the agreement to be something else-that it barred the state from petitioning for the civil commitment absent future sexual misconduct-or the fact that appellant's attorney later made the same claim[6] does not create an ambiguity. The terms of the plea are not susceptible to more than one meaning. An after-the-fact assertion that *859 the terms were different does not render ambiguous that which was clear and unequivocal when the agreement was made.
While our ruling need not be based on anything more than the record of the plea proceeding, we note that appellant's attorney testified that the sole purpose of entering the plea agreement was to avoid a future referral of civil commitment by the court, and this argument has been advanced repeatedly throughout this appeal. Appellant apparently had a different point of view however, as he testified on June 15, 1998 that he pled for two reasons-to avoid civil commitment and to avoid the risk of a 37 year prison sentence as opposed to the 10 year sentence he received. Avoiding civil commitment was an important consideration to appellant in 1991, but by his own testimony it was not the only consideration, nor does it defy logic that he would enter into such an agreement even if he could be committed at the end of his sentence.
The plea agreement here unambiguously stated that the court would not refer appellant for civil commitment at the time of sentencing, and because the court upheld its end of the bargain, the plea agreement terms were satisfied.[7]
Affirmed.
NOTES
[1]  "When a court sentences a person under [statutes covering criminal sexual conduct] the court shall make a preliminary determination whether in the court's opinion a petition * * * may be appropriate." Minn.Stat. § 609.1351 (1990).
[2]  Minn.Stat. § 609.1352 was repealed and recodified as Minn.Stat. § 609.108 (1998). See Act of Apr. 6, 1988, ch. 367, art. 6, §§ 5, 15, 16, 1998 Minn. Laws 727-28, 734-35. Minn. Stat. § 609.108, subd. 1, states in relevant part:

A court shall commit a person to the commissioner of corrections for a period of time that is not less than double the presumptive sentence under the sentencing guidelines and not more than the statutory maximum * * * if:
(1) the court is imposing [an executed sentence] * * * on a person convicted of committing or attempting to commit [criminal sexual conduct] * * * if it reasonably appears to the court that the crime was motivated by the offender's sexual impulses or was part of a predatory pattern of behavior that had criminal sexual conduct as its goal;
(2) the court finds that the offender is a danger to public safety; and
(3) the court finds that the offender needs long-term treatment or supervision beyond the presumptive term of imprisonment and supervised release * * *.
Minn.Stat. § 609.108, subd. 1 (1998).
[3]  "Before commitment proceedings are instituted, the facts shall first be submitted to the county attorney, who, if satisfied that good cause exists, will prepare the petition." Minn.Stat. § 253B.185, subd. 1.
[4]  Minn.Stat. § 253B.02, subd. 18b (1998), defines a sexual psychopathic personality as the existence of conditions such as:

emotional instability, or impulsiveness of behavior, or lack of customary standards of good judgment, or failure to appreciate the consequences of personal acts, * * * which render the person irresponsible for personal conduct with respect to sexual matters, if the person has evidenced, by a habitual course of misconduct in sexual matters, an utter lack of power to control the person's sexual impulses and, as a result, is dangerous to other persons.
Minn.Stat. § 253B.02, subd. 18c (1998), defines "sexually dangerous person" as a person who:
(1)has engaged in a course of harmful sexual conduct * * *;
(2) has manifested a sexual, personality, or other mental disorder or dysfunction; and
(3) as a result, is likely to engage in acts of harmful sexual conduct * * *.
[5]  "While in prison, [appellant] has been involved in a number of altercations. [Appellant] has been disciplined for fighting, gambling and for possession of drugs. In late 1993, [appellant] had a nail studded board with which he intended to harm another inmate with whom he had had a physical altercation." DOC Petition for Civil Commitment at 4-5.
[6]  Taking into account the plea transcript, appellant's attorney's October 12 testimony and her affidavit there are no less than three versions of the 1991 plea agreement: first, the agreement prohibited a judicial recommendation "at the time of sentencing"; second, the agreement prohibited the state from initiating civil commitment procedures against appellant for that particular crime; and third, the agreement prohibited the state from ever using that crime, or appellant's previous crimes, in a civil commitment determination. Far from shedding light on the parties' intent, the attorney's testimony only casts a cloud of confusion over an otherwise unambiguous agreement.
[7]  We have strong reservations as to whether either the county attorney or the district court had authority to enter into a plea agreement that would preclude the filing of a petition for civil commitment as appellant claims, but we need not reach that issue. In Call v. Gomez, 535 N.W.2d 312, 320 (Minn.1995), we held that civil commitment is remedial because it is for treatment purposes, not for preventive detention and in In re Linehan, 557 N.W.2d 171, 187-89 (Minn.1996), we held that the purpose of Minn.Stat. § 253B.02 subd. 18c, which established procedures for civilly committing criminally dangerous people, was for treatment, and thus the act was facially civil and not punitive. As the court of appeals observed, we note that a determination of good cause to initiate a petition for civil commitment involves different considerations than a county attorney's decision whether to accept a plea.
