                 FOR PUBLICATION
 UNITED STATES COURT OF APPEALS
      FOR THE NINTH CIRCUIT

BRIAN A. BUCKLEY,                     
               Petitioner-Appellee,
                                           No. 03-55045
                v.
C.A. TERHUNE, Director of the               D.C. No.
                                          CV-00-02435-JSL
California Department of
                                             OPINION
Corrections,
             Respondent-Appellant.
                                      
       Appeal from the United States District Court
           for the Central District of California
        J. Spencer Letts, District Judge, Presiding

                 Argued and Submitted
      September 27, 2005—San Francisco, California

                   Filed March 17, 2006

Before: Mary M. Schroeder, Chief Judge, Stephen Reinhardt,
          Alex Kozinski, M. Margaret McKeown,
        Kim McLane Wardlaw, Raymond C. Fisher,
  Richard A. Paez, Marsha S. Berzon, Richard C. Tallman,
 Jay S. Bybee, and Consuelo M. Callahan, Circuit Judges.

               Opinion by Judge Reinhardt;
                Dissent by Judge Callahan




                           2809
                    BUCKLEY v. TERHUNE                2813


                       COUNSEL

Allen Bloom, San Diego, California, for the petitioner-
appellee.

Bill Lockyer, Attorney General; Robert R. Anderson, Chief
Assistant Attorney General; Pamela C. Hamanaka, Senior
Assistant Attorney General; Kenneth C. Byrne, Supervising
Deputy Attorney General; Noah P. Hill, Deputy Attorney
General; Los Angeles, California, for the respondent-
appellant.


                        OPINION

REINHARDT, Circuit Judge:

  The law regarding plea agreements entered into in state
court is well-established. They must be construed in accor-
2814                  BUCKLEY v. TERHUNE
dance with state law. In California, plea agreements are con-
strued in the same manner as all other contracts. In this case,
however, the California courts failed to do so and, as a result,
Brian Buckley might have remained in prison for life instead
of for the fifteen years for which he bargained. We are
required to ensure that his constitutional rights are not so vio-
lated, and that the bargain he entered into with the state is
honored.

   The state appeals the district court’s order granting Buck-
ley’s petition for a writ of habeas corpus and directing that he
be released from prison because he had already served the full
fifteen years. The district court ruled that the state court’s
finding that Buckley “well knew” that his sentence for second
degree murder was fifteen years to life was both contrary to
clearly established federal law in violation of 28 U.S.C.
§ 2254(d)(1) and an unreasonable determination of the facts
in violation of § 2254(d)(2). In accordance with the district
court’s order, Buckley has now been released. We affirm the
judgment of the district court because, under § 2254(d)(1), the
state court’s failure to interpret Buckley’s plea agreement
according to California contract law resulted in a decision that
was contrary to clearly established Supreme Court law as set
forth in Santobello v. New York, 404 U.S. 257 (1971), and
Ricketts v. Adamson, 483 U.S. 1 (1987).

    FACTUAL AND PROCEDURAL BACKGROUND

   On November 12, 1987, Buckley was charged with bur-
glary, robbery and first degree murder in Ventura County
Superior Court. The charges arose from allegations that Buck-
ley and two others, Curtis Fauber and Christopher Caldwell,
robbed and killed Thomas Urell in his home in July 1986.

   On December 15, 1987, Donald Glynn, the deputy district
attorney assigned to Buckley’s case, sent Buckley’s attorney
a letter offering a plea bargain. The letter stated that, in
exchange for Buckley’s sworn testimony describing Fauber
                        BUCKLEY v. TERHUNE                       2815
and Caldwell’s participation in the Urell murder and in two
additional unrelated murders, Glynn would dismiss the rob-
bery and burglary charges against Buckley and move the
court to declare the murder charge against him to be murder
in the second degree. The letter was silent as to the sentence
Buckley would receive. Glynn attached to the letter a type-
written felony disposition statement. That document con-
tained the following relevant language:

      CONSEQUENCES OF PLEA (Defendant to initial)

      My attorney has explained to me the direct and indi-
      rect consequences of this plea including the maxi-
      mum possible sentence. I understand that the
      following consequences could result from my plea:

      I could be sentenced to the state prison for a maxi-
      mum possible term of 15 year(s).

      ***

      After I have served my prison term, I may be subject
      to a maximum parole period of LIFE (In re Carabes,
      144 Cal. App. 3d 927).1

(Emphasis added). On December 17, 1987, Buckley initialed
the paragraphs describing his agreed-upon sentence and
signed the statement.

   The district court found that at the time Buckley initialed
and signed the felony disposition statement, a separate section
of that document entitled “The District Attorney’s Position on
Sentence” was blank. At some point after December 17, 1987,
but before the change of plea hearing on January 4, 1988,
  1
   The number “15” was handwritten. The word “LIFE” was not added
until the January 4, 1988, plea hearing. However, the question of Buck-
ley’s parole term is not at issue here.
2816                 BUCKLEY v. TERHUNE
Glynn added a handwritten paragraph to that section: “At the
time of sentencing the people will move the court to declare
the murder to be murder in the second degree, with a maxi-
mum term of 15 years to life.” (Emphasis added). Buckley did
not initial the paragraph, and there is no evidence that he saw
it before sentencing.

   At the change of plea hearing, Glynn and Buckley engaged
in the following colloquy:

    Q: And has your attorney explained all of the con-
    sequences of your plea to this charge?

    A:   Yes.

    Q: Do you understand that for second degree mur-
    der you could be sentenced to state prison for a max-
    imum possible term of fifteen years?

    A:   Yes.

    Q: And do you understand that after serving a
    prison term you’ll be subject to a parole period —
    I’m sorry, your Honor, does the Court know the
    parole period for second degree murder? I didn’t
    enter that in the document.

    The Court:    Yes, it’s — the possibility is parole for
    life.

    Q: All right. I’ve entered this into the document.
    You could be subject to a parole period of life. And
    you could also be ordered to pay a fine of not less
    than a hundred dollars nor more than $10,000. Do
    you understand that?

    A:   Yes.
                 BUCKLEY v. TERHUNE                       2817
***

Q: Now as I stated before and it’s also contained
in this Felony Disposition form, that at the time of
sentencing the people will ask the Court to declare
the murder to be murder in the second degree with
a maximum term of fifteen years to life. And the Peo-
ple’s reason for entering into that agreement are [sic]
contained in this document that’s attached to the Fel-
ony Disposition Statement.

I’d like to go into the terms of this agreement with
you. In order — or as your part of the agreement you
will agree to cooperate in the trials against Curtis
Fauber and Christopher Cogwell [sic], and that you
will testify in the Fauber case at all proceedings
regarding the murder of Thomas Urell, David
Church and Jack Dowdy, and testify truthfully
regarding whatever you know about those murders.
Do you understand that to be the situation?

A:    Yes.

***

Q: I’m showing you the Felony Disposition form,
this yellow form here, that has some initials B.B.
against a number of the paragraphs. Also has the ini-
tials D.C.G. which are my initials against some of
the paragraphs. And at the end of the form I see the
date December 17, 1987 and your signature. Did you
sign this document on that date?

A:    Yes.

Q: And did you sign this document because you
read each of the paragraphs that you have initialed
2818                     BUCKLEY v. TERHUNE
      and you understand what’s contained in these para-
      graphs?

      A:   Yes.

(Emphasis added). The December 15 letter and the felony dis-
position statement were entered into evidence as constituting
the plea agreement, and the court accepted and entered Buck-
ley’s guilty plea.

   On January 7, 1988, Buckley testified on behalf of the pros-
ecution at the guilt phase of Fauber’s trial. On cross-
examination, Buckley stated that he had been given a sentence
of “fifteen years to life” in exchange for his testimony. On
January 22, 1988, Buckley testified for the prosecution at a
preliminary hearing in Caldwell’s case. There, he acknowl-
edged that his charged offense had been reduced to second
degree murder, although there was no discussion of his sen-
tence. On February 9, 1988, Buckley testified at the penalty
phase of Fauber’s trial. On cross-examination, when asked by
defense counsel when he “expect[ed] to be released from pris-
on” as a result of his testimony, Buckley responded, “seven
and a half years.”2

   Buckley’s sentencing hearing took place on March 1, 1988,
after his testimony in the Fauber and Caldwell cases. At the
hearing, Glynn informed the court that Buckley had “com-
plied with the terms of the negotiated disposition.” The prose-
cutor moved the court to declare the murder charge against
Buckley to be murder in the second degree, and to dismiss the
remaining two counts. The court granted the motion, ordered
Buckley to pay $10,000 in restitution, and sentenced him to
  2
   Buckley’s statement that he expected to be released from prison in
seven and a half years apparently reflected his erroneous belief that under
California law he would be released after he had served half of his sen-
tence if he exhibited good behavior. See CAL. PENAL CODE § 3049.
                          BUCKLEY v. TERHUNE                            2819
a prison term of fifteen years to life and a parole term of life.
Buckley’s counsel did not object to the sentence.3

   On May 13, 1996, approximately eight years after Buck-
ley’s sentencing, he filed a petition for a writ of habeas corpus
in the Ventura County Superior Court. On September 10,
1996, the court, in a two-page order, denied Buckley’s peti-
tion:

        The court finds that with the exception of one
     statement in the negotiated disposition statement . . .
     and a reference at the time of the taking of the plea
     on January 4, 1988, . . . the records demonstrate that
     the advisement was that the sentence would be 15
     years to life as provided by law, and that the peti-
     tioner well knew this . . . . During the taking of the
     plea on January 4, 1988, [ ] petitioner was expressly
     advised that the maximum term of imprisonment
     was 15 years to life . . . . Any ambiguity concerning
     petitioner’s understanding of the sentence he was to
     receive is put to rest by petitioner’s own statement
     found in the transcript of January 7, 1988, during
     petitioner’s testimony at the trial of Curtis Fauber
     that he understood his term of imprisonment would
     be 15 years to life . . . .
   3
     Despite the sentence of fifteen years to life in prison, Buckley contends
that he believed that the maximum prison sentence he faced was fifteen
years. According to Buckley, this belief resulted from the explicit terms
of the plea agreement he saw and initialed, the colloquy at the change of
plea hearing (in which he answered “yes” to the prosecutor’s question
whether he signed the plea agreement because he read and understood
each of the paragraphs that he initialed), and his understanding that “fif-
teen to life” was simply another way of saying “fifteen years in prison fol-
lowed by a parole term of life.” There is no evidence that Buckley’s trial
counsel explained to him the difference between the two sentences.
According to Buckley, he did not discover that his sentence was actually
an indeterminate term of fifteen years to life until a 1995 administrative
hearing in prison.
2820                     BUCKLEY v. TERHUNE
      ***

         Based upon the record provided by counsel in the
      within matter, it is evident that petitioner well knew
      that the term of imprisonment for which he was to be
      committed to prison for the crime of second degree
      murder was 15 years to life. In re Mosher [sic],
      (1993) 6 Cal. 4th 342, 354-355, citing United States
      vs. Timmreck (1979) 441 US 780, 784.

(Emphasis added). Buckley next filed a habeas petition in the
California Court of Appeal, which issued a one-sentence sum-
mary denial. The California Supreme Court also issued a one-
sentence summary denial of a separate successive petition on
March 31, 1999.

   Buckley filed a petition for a writ of habeas corpus in dis-
trict court on March 7, 2000.4 The court referred the case to
a magistrate judge, who ordered an evidentiary hearing. The
magistrate judge issued a report that recommended granting
the writ. He found that, under 28 U.S.C. § 2254(d)(2), Buck-
ley had demonstrated by clear and convincing evidence that
the state court’s factual finding regarding Buckley’s subjec-
tive understanding of his sentence was “incorrect and unrea-
sonable.” Buckley v. Terhune, 266 F. Supp. 2d 1124, 1141
(C.D. Cal. 2002). Based on this finding, the magistrate judge
concluded that, under § 2254(d)(1), the trial court had failed
to “fulfill petitioner’s reasonable understanding of the plea
agreement,” which was contrary to clearly established federal
law holding that the state must fulfill a promise that induces
a guilty plea. Id. at 1142-43. The magistrate judge recom-
  4
   The one-year statute of limitations applicable to Buckley’s federal
habeas petition was tolled from the time that he filed his initial state
habeas petition to thirty days after the California Supreme Court denied
his last petition. Carey v. Saffold, 536 U.S. 214, 221-23 (2002); Nino v.
Galaza, 183 F.3d 1003, 1006-07 (9th Cir. 1999). Thus, his federal petition
was timely, and the state does not contend otherwise.
                     BUCKLEY v. TERHUNE                   2821
mended specific performance of the plea agreement: a deter-
minate sentence of fifteen years in prison. Id. at 1143. The
district court adopted the magistrate judge’s report and recom-
mendation, id. at 1126, and the state appealed.

  We affirm, although our analysis differs from the district
court’s in some respects.

                 STANDARD OF REVIEW

   The district court’s decision to grant a 28 U.S.C. § 2254
habeas petition is reviewed de novo. See Leavitt v. Arave, 383
F.3d 809, 815 (9th Cir. 2004) (per curiam). We may affirm on
any ground supported by the record, even if it differs from the
rationale used by the district court. See Ramirez v. Castro,
365 F.3d 755, 762 (9th Cir. 2004). We review findings of fact
made by the district court for clear error. See Riley v. Payne,
352 F.3d 1313, 1317 (9th Cir. 2003).

   Under the Antiterrorism and Effective Death Penalty Act
(AEDPA), § 2254 habeas petitions “shall not be granted with
respect to any claim that was adjudicated on the merits in
State court proceedings unless the adjudication of the claim
— (1) resulted in a decision that was contrary to, or involved
an unreasonable application of, clearly established Federal
law, as determined by the Supreme Court of the United
States; or (2) resulted in a decision that was based on an
unreasonable determination of the facts in light of the evi-
dence presented in the State court proceeding.” 28 U.S.C.
§ 2254(d); see also Lockyer v. Andrade, 538 U.S. 63, 70-73
(2003). Because Buckley filed his federal habeas petition after
AEDPA’s effective date, we review his petition under the
AEDPA standard. See Lindh v. Murphy, 521 U.S. 320, 326-27
(1997).

                         ANALYSIS

  [1] Under Santobello v. New York, 404 U.S. 257, 261-62
(1971), a criminal defendant has a due process right to
2822                      BUCKLEY v. TERHUNE
enforce the terms of his plea agreement. See also Brown v.
Poole, 337 F.3d 1155, 1159 (9th Cir. 2003) (“[The defen-
dant’s] due process rights conferred by the federal constitu-
tion allow [him] to enforce the terms of the plea agreement.”).
In March 1999, when the California Supreme Court summa-
rily denied Buckley’s petition for a writ of habeas corpus, it
had been clearly established federal law for more than a
decade that the construction and interpretation of state court
plea agreements “and the concomitant obligations flowing
therefrom are, within broad bounds of reasonableness, matters
of state law.” Ricketts v. Adamson, 483 U.S. 1, 6 n.3 (1987).
In California, “[a] negotiated plea agreement is a form of con-
tract, and it is interpreted according to general contract princi-
ples,” People v. Shelton, 37 Cal. 4th 759, 767 (2006), and
“according to the same rules as other contracts,” People v.
Toscano, 124 Cal. App. 4th 340, 344 (2004) (cited with
approval in Shelton along with other California cases to same
effect dating back to 1982). Thus, under Adamson, California
courts are required to construe and interpret plea agreements
in accordance with state contract law.

   The analysis regarding the breach of Buckley’s plea agree-
ment and the remedy to which he is entitled is not new to this
court. We previously applied similar principles and rules of
construction in Brown. In that case, on the basis of Santobello
and Adamson, we held that the state court, in failing to prop-
erly apply California contract law when interpreting a plea
agreement, had engaged in an objectively unreasonable appli-
cation of clearly established federal law under § 2254(d)(1).
Brown, 337 F.3d at 1160 n.2. Here the California Superior
Court not only failed to apply state contract law properly but
failed to apply it at all. Its decision, therefore, is unquestion-
ably contrary to clearly established federal law.5
  5
    The “unreasonable application” provision of § 2254(d)(1) applies
where “the state court identifies the correct governing legal principle from
[the Supreme Court’s] decisions but unreasonably applies that principle to
the facts of the prisoner’s case.” Williams v. Taylor, 529 U.S. 362, 413
                          BUCKLEY v. TERHUNE                           2823
                                     I

   [2] In California, “[a]ll contracts, whether public or private,
are to be interpreted by the same rules . . . .” CAL. CIV. CODE
§ 1635; see also Shelton, 37 Cal. 4th at 766-67; Toscano, 124
Cal. App. 4th at 344. A court must first look to the plain
meaning of the agreement’s language. CAL. CIV. CODE
§§ 1638, 1644. If the language in the contract is ambiguous,
“it must be interpreted in the sense in which the promisor
believed, at the time of making it, that the promisee under-
stood it.” CAL. CIV. CODE § 1649. The inquiry considers not
the subjective belief of the promisor but, rather, the “objec-
tively reasonable” expectation of the promisee. Bank of the
West v. Superior Court, 2 Cal. 4th 1254, 1265 (1992); Badie
v. Bank of Am., 67 Cal. App. 4th 779, 802 n.9 (1998)
(“Although the intent of the parties determines the meaning of
the contract, the relevant intent is objective — that is, the
objective intent as evidenced by the words of the instrument,
not a party’s subjective intent.” (internal quotation marks and
citation omitted)). Courts look to the “objective manifesta-
tions of the parties’ intent . . . .” Shelton, 37 Cal. 4th at 767.
If after this second inquiry the ambiguity remains, “the lan-
guage of a contract should be interpreted most strongly
against the party who caused the uncertainty to exist.” CAL.
CIV. CODE § 1654; see also Toscano, 124 Cal. App. 4th at 345
(“ambiguities [in a plea agreement] are construed in favor of
the defendant”).

(2000). In this case, however, the state court’s decision was “contrary to”
clearly established law because it failed to apply contract law analysis at
all: “[A] state court decision is contrary to our clearly established prece-
dent if the state court applies a rule that contradicts the governing law set
forth in our cases . . . .” Andrade, 538 U.S. at 73 (internal quotation marks
omitted). Whether we classify this case as an “unreasonable application
of” or a “contrary to” case is irrelevant, however; the result would be the
same in either instance.
2824                      BUCKLEY v. TERHUNE
   [3] Our first inquiry here is whether the Ventura County
Superior Court, in the last reasoned state court decision to
address Buckley’s plea agreement, treated the plea agreement
as a contract and applied the three-step approach to interpret-
ing contracts required by California law. Initially, we note
that there is no mention of or reference to state contract law
in the Superior Court’s order denying Buckley’s habeas peti-
tion. Nor is there any discussion of the terms of the plea
agreement. Instead, the order addresses whether Buckley was
“expressly advised” by the trial court that his sentence was
fifteen years to life, and it cites only cases that consider an
“advisement” issue — that is, the issue of a trial court’s duty
to explain the charge and the sentence to a defendant. On the
basis of this analysis it concluded that Buckley knew what his
sentence would be.6 It is evident on the face of its decision
that the Superior Court failed to recognize that Buckley’s plea
agreement constituted a contract that under California law
must be construed like all other contracts. As a result, the
Superior Court failed to construe the terms of the plea agree-
ment entirely. Accordingly, it failed to apply controlling state
law and reached a decision that both in its mode of analysis
and its result was contrary to clearly established Supreme
Court law.

   [4] Considering extrinsic evidence before examining the
language of the plea agreement and finding it ambiguous, as
the state court did in this case, is further evidence of its failure
  6
    The Superior Court’s order principally cites In re Moser, 6 Cal. 4th
342, 354-55 (1993) (although it misspells the case name). Moser was a
state habeas case in which the defendant pled guilty “after receiving inade-
quate or erroneous advice from the trial court” with respect to the possible
consequences of his plea agreement. Id. at 345. As the Moser court held,
the issue in that case was “misadvisement,” not the breach of a plea agree-
ment. Id. at 356. Similarly, United States v. Timmreck, 441 U.S. 780
(1979), which the Superior Court notes was cited in Moser, involves the
trial court’s failure to properly advise the defendant regarding his sentence
as required by Federal Rule of Criminal Procedure 11. Again in Timmreck,
as in Moser, the issue was not the breach of a plea agreement but a breach
of the trial court’s duty to inform the defendant of certain information.
                          BUCKLEY v. TERHUNE                            2825
to apply California contract law. CAL. CIV. CODE § 1638; Pope
v. Allen, 225 Cal. App. 2d 358, 364 (1964) (“The code provi-
sion permitting the showing of surrounding circumstances is
not applicable to every contract which comes before a court
for interpretation. It is applicable only where the language
used in the contract is doubtful, uncertain or ambiguous
. . . .”). Moreover, even if the Ventura County Superior Court
had first considered the plea agreement’s language and con-
cluded that it was ambiguous, the court was not then permit-
ted to use parol evidence to gauge the subjective
understanding of one of the contracting parties.7 See Bank of
the West, 2 Cal. 4th at 1264 65; Beck v. Am. Health Group
Int’l, Inc., 211 Cal. App. 3d 1555, 1562 (1989) (“The objec-
tive intent . . . not the parties’ subjective intent, governs our
interpretation.”). In failing first to consider the language of
Buckley’s plea agreement and second to engage in an analysis
of the parties’ objective intent in entering that agreement, the
Superior Court plainly contravened California law. In light of
Santobello and Adamson, its decision falls squarely within the
ambit of § 2254(d)(1).
  7
    The dissent, on the one hand, argues that the state court’s finding that
Buckley “well knew” that his sentence was fifteen years to life is entitled
to our deference under AEDPA. On the other hand, it concedes that the
state court failed both to examine the language of the plea agreement and
to apply an objective test to determine the mutual intent of the parties. Dis-
sent at 2833 n.1 (“It is true that the California Superior Court did not spec-
ify that the plea agreement should be interpreted pursuant to general
contract terms. Nonetheless, the application of those terms would not have
changed that court’s factual determination.”). As to our dissenting col-
leagues’ first point, whether or not the state court’s determination of Buck-
ley’s subjective state of mind was reasonable is wholly irrelevant. The fact
remains that the court failed to apply California contract law or to analyze
Buckley’s plea agreement in that light, or indeed in any light. Although
AEDPA does require deference to a state court’s factual findings, it does
not permit us, as the dissent suggests, to invent factual findings and then
ascribe them to the state court. Nor does it allow us to attribute a theory
of law to the state court that it failed to employ.
2826                      BUCKLEY v. TERHUNE
                                    II

   [5] Under AEDPA, even where the state court has commit-
ted constitutional error under § 2254(d), “habeas relief may
still be denied absent a showing of prejudice.” Medina v.
Hornung, 386 F.3d 872, 877 (9th Cir. 2004). The relevant
inquiry in this case is whether the state court’s error, which
resulted in its finding that the plea agreement mandated an
indeterminate prison sentence of fifteen years to life, had a
“substantial and injurious effect” on Buckley. Brecht v.
Abrahamson, 507 U.S. 619, 637 (1993). To answer this ques-
tion we must determine what Buckley’s sentence would have
been had the California courts applied California contract law.
Where the state court fails to apply Supreme Court law (by
failing to apply California contract law) we must ourselves
conduct a de novo review of that question.

   [6] With respect to the first step in California contract anal-
ysis, it is clear that the language of Buckley’s plea agreement
was ambiguous. Critically, the plea agreement contained con-
flicting paragraphs describing the sentence to be given Buck-
ley upon his plea of guilty to second degree murder. One
paragraph, which Buckley initialed, stated, “I could be sen-
tenced to the state prison for a maximum possible term of 15
year(s) . . . . After I have served my prison term, I may be
subject to a maximum parole period of LIFE.” A different
paragraph was added later, after Buckley had already read and
initiated the agreement. That paragraph, initialed only by
Glynn, stated, “At the time of sentencing the people will
move the court to declare the murder to be murder in the sec-
ond degree, with a maximum term of 15 years to life.”8 Even
  8
    The district court found that the additional paragraph, which was hand-
written, was not added until after Buckley saw and initialed the first para-
graph. There appears to be no doubt from the record that the district court
is correct in this respect. However, the chronology is not important to our
outcome here: For purposes of this opinion we attach no weight to the fact
that the state’s version of the bargained-for sentence was incorporated in
                         BUCKLEY v. TERHUNE                         2827
disregarding the timing of the addition of the added para-
graph, there is only one reasonable conclusion one can draw
from the facts: The language of the plea agreement is ambigu-
ous with respect to Buckley’s sentence.

   [7] After finding an ambiguity in the language of a con-
tract, we must next attempt to resolve that uncertainty by
looking to the “objectively reasonable expectations” of the
promisee. See Bank of the West, 2 Cal. 4th at 1265; CAL. CIV.
CODE § 1649. This inquiry considers the disputed or ambigu-
ous language in the context of the contract as a whole and of
the relevant surrounding circumstances. Nissel v. Certain
Underwriters at Lloyd’s of London, 62 Cal. App. 4th 1103,
1111-12 (1998); see also Bank of the West, 2 Cal. 4th at 1265
(“This is because language in a contract must be construed in
the context of that instrument as a whole, and in the circum-
stances of that case, and cannot be found to be ambiguous in
the abstract.” (emphasis and internal quotation marks omit-
ted)).

   [8] Applying the second step of California contract analysis
in this case does not resolve the ambiguity created by the lan-
guage of the plea agreement. Read in the context of the entire
agreement, the conflicting pronouncements regarding the
length of the sentence to be imposed offer no more clarity
than they do when read in the abstract. Furthermore, the plea
colloquy compounds, rather than cures, this ambiguity. At the
January 4, 1988, change of plea hearing, Glynn asked Buck-
ley whether he understood his sentence to be “a maximum
possible term of fifteen years,” to which Buckley responded,
“Yes.” However, shortly thereafter, Glynn stated, “Now as I

the plea agreement after Buckley had reviewed and initialed it, and afford
that version equal significance to the paragraph on which Buckley relies,
although we note that were we to disregard the subsequently incorporated
material, there would be no inconsistency and no ambiguity at all, as
Buckley’s version of the sentence would be the only one set forth in the
plea agreement.
2828                      BUCKLEY v. TERHUNE
stated before and it’s also contained in this Felony Disposition
form, that at the time of sentencing the people will ask the
Court to declare the murder to be murder in the second degree
with a maximum term of fifteen years to life . . . . Do you
understand that to be the situation?” Again, Buckley
answered, “Yes.” Accordingly, the colloquy does no more
than replicate the ambiguity and, in turn, lead us to the final
step in our contractual analysis.9

   [9] The proper interpretation of the plea agreement
becomes clear when we turn, as California law provides, to
§ 1654 of the California Civil Code: “In cases of uncertainty
not removed by the preceding rules, the language of a contract
should be interpreted most strongly against the party who
caused the uncertainty to exist.” There is no dispute that both
the December 15, 1987, letter from Glynn to Buckley’s coun-
sel and the felony disposition statement, which together con-
stituted the plea agreement, were drafted by the prosecutor’s
office. Thus, we are compelled by § 1654 to construe the
ambiguity in the plea agreement — whether Buckley was to
receive a determinate fifteen-year sentence or an indetermi-
nate sentence of fifteen years to life — against the state. See
Toscano, 124 Cal. App. 4th at 345. Given the direct conflict
in the terms of the plea agreement, we must adopt the con-
struction of the agreement that is most favorable to Buckley:
a maximum prison sentence of fifteen years. Because Buckley
instead received an indeterminate prison sentence of fifteen
years to life, it is evident that the state breached the plea
agreement and that the breach had a “substantial and injurious
effect” upon Buckley. Brecht, 507 U.S. at 637.
  9
    That Buckley subsequently testified at his co-defendant’s trial and sen-
tencing both that he had received a sentence of fifteen years to life and that
he expected to be released from prison in seven and one half years only
compounds the ambiguity further. Finally, given Buckley’s later expressed
misunderstanding of the relationship between his prison sentence and his
parole term, and the absence of any evidence that counsel explained to
him the nature of his sentence, his failure to object to the sentence when
it was ultimately imposed by no means serves to eliminate the ambiguity.
                          BUCKLEY v. TERHUNE                          2829
                                    III

  [10] As the district court found, Buckley has two available
remedies at law for the breach of his plea agreement: with-
drawal of his plea (i.e., rescission of the contract) and specific
performance. Buckley, 266 F. Supp. 2d at 1143; see also San-
tobello, 404 U.S. at 263 (positing the same two alternative
remedies). Where a plea agreement is breached, the purpose
of the remedy is, to the extent possible, to “repair the harm
caused by the breach.” Toscano, 124 Cal. App. 4th at 345 (cit-
ing People v. Kaanehe, 19 Cal. 3d 1, 14 (1977)).

   [11] In Buckley’s case, only one of the remedies appears to
us to be viable. Buckley has already fulfilled his obligations
under the plea agreement, including testifying on behalf of the
state against Fauber and Caldwell and serving his bargained-
for sentence.10 In so doing, he has “paid in a coin that the state
cannot refund.” Brown, 337 F.3d at 1161. Rescission of the
plea agreement cannot repair the harm caused by the state’s
breach. See Carter v. McCarthy, 806 F.2d 1373, 1377 (9th
Cir. 1986). That harm can best be addressed by holding the
state to its agreement and affording Buckley the benefit of his
bargain.11 Thus, Buckley is entitled to specific performance of
  10
      Buckley was taken into custody on November 12, 1987, the date that
he was charged with burglary, robbery and first degree murder. The dis-
trict court granted him habeas relief on December 6, 2002. He was thereaf-
ter released.
   11
      We express no view on what the proper remedy would be in a case
with other facts. As the California Supreme Court has held, the appropri-
ate remedy in breach of plea agreement cases depends on the nature of the
breach, which party (e.g., the defendant, the prosecutor or the trial court)
has breached the agreement, and which party seeks enforcement of the
contract. Kaanehe, 19 Cal. 3d at 13. To that we would add, “and what has
transpired since the agreement was made.” Here, we hold only that in a
case in which the state has already received the benefit of the bargain, the
harm caused by its breach is generally best repaired by specific perfor-
mance of the plea agreement, although a defendant may, if he so chooses,
elect instead to rescind the agreement and take his chances from there.
2830                  BUCKLEY v. TERHUNE
the plea agreement: a maximum prison sentence of fifteen
years.

   We arrive at our decision notwithstanding the state’s argu-
ment that a determinate fifteen year prison term is not a law-
ful sentence for second degree murder under California law.
Consistent or not with the state’s sentencing statute, that is the
bargain that California made in 1987. Buckley has fulfilled
his promises, and it is now too late for the state to argue that
it was not in a position to offer him a fifteen year sentence in
exchange. As we stated in Brown, addressing an identical
argument: “This may be a problem for the state, but not for
[the defendant].” 337 F.3d at 1161.

                               IV

   [12] Under Santobello, Buckley had a due process right to
enforce the provisions of his plea agreement. Under Adamson,
the state court was required to interpret Buckley’s plea agree-
ment pursuant to California contract law; in not doing so, it
failed to apply clearly established federal law set forth by the
United States Supreme Court. 28 U.S.C. § 2254(d)(1). The
consequence was that Buckley was sentenced to an indetermi-
nate prison term of fifteen years to life when the bargained-for
sentence, to which he was constitutionally entitled, was a
maximum of fifteen years. Thus, the state court committed
constitutional error that had a substantial and injurious effect
on Buckley. He is entitled to habeas corpus relief.

   The district court’s judgment granting Buckley’s petition
for a writ of habeas corpus is AFFIRMED.



CALLAHAN, Circuit Judge, with whom Tallman, Circuit
Judge, joins, dissenting:

   I respectfully dissent. The majority notes the standard for
relief set forth in the Antiterrorism and Effective Death Pen-
                      BUCKLEY v. TERHUNE                    2831
alty Act (“AEDPA”), 28 U.S.C. § 2254, but then substitutes
its factual findings for those of the state court. Although the
majority professes to grant relief under § 2254(d)(1), holding
that the state court’s decision involved an unreasonable appli-
cation of clearly established federal law, my reading of its
opinion is that it actually, and incorrectly, concludes that the
state court’s decision was based on an unreasonable determi-
nation of fact. See 28 U.S.C. § 2254(d)(2).

   The majority’s perspective rests on two premises. First, it
asserts that it was established federal law in 1999, that the
construction and interpretation of plea agreements were mat-
ters of state law and that in California a plea agreement was
interpreted according to the same rules as other contracts.
Second, the majority concludes that under California law, the
uncertainty in the plea agreement requires that the agreement
be construed against the state.

   I agree with the majority that the construction and interpre-
tation of plea agreements are matters of state law, that in Cali-
fornia plea agreements are interpreted similarly to other
contracts, and that here the plea agreement is ambiguous. I
also agree that the ambiguity in the plea agreement requires
that we look to the expectations of the promisee in the context
of the contract as a whole and the relevant surrounding cir-
cumstances. I part company with the majority on the conclu-
sions we reach from examining the surrounding
circumstances. The majority finds that the surrounding cir-
cumstances do not resolve the ambiguity. AEDPA, however,
requires that we defer to the state court’s factual determina-
tion that Buckley “well knew” that he had bargained for a
sentence of 15 years to life unless that finding is not sup-
ported by substantial evidence. Taylor v. Maddox, 366 F.3d
992, 999 (9th Cir. 2004). Because I cannot say “that an appel-
late panel, applying the normal standard of appellate review,
could not reasonably conclude that the finding is supported by
the record,” see id. at 1000, I would deny Buckley’s petition
for a writ of habeas corpus.
2832                  BUCKLEY v. TERHUNE
   In its most recent opinion concerning the interpretation of
plea agreements, the California Supreme Court, after reiterat-
ing that a plea agreement is interpreted according to general
contract principles, wrote:

    “The fundamental goal of contractual interpretation
    is to give effect to the mutual intention of the parties.
    (Civ. Code, § 1636.) If contractual language is clear
    and explicit, it governs. (Civ. Code, § 1638.) On the
    other hand, ‘[i]f the terms of a promise are in any
    respect ambiguous or uncertain, it must be inter-
    preted in the sense in which the promisor believed,
    at the time of making it, that the promisee under-
    stood it.’ (Id., § 1649; see AIU [Ins. Co. v. Superior
    Court (1990) 51 Cal.3d 807,] 822 [274 Cal. Rptr.
    820, 799 P.2d 1253].)” (Bank of the West v. Superior
    Court (1992) 2 Cal.4th 1254, 1264-1265, 10 Cal.
    Rptr. 2d 538, 833 P.2d 545.) “The mutual intention
    to which the courts give effect is determined by
    objective manifestations of the parties’ intent,
    including the words used in the agreement, as well
    as extrinsic evidence of such objective matters as the
    surrounding circumstances under which the parties
    negotiated or entered into the contract; the object,
    nature and subject matter of the contract; and the
    subsequent conduct of the parties. (Civ. Code,
    §§ 1635-1656; Code Civ. Proc., 1859-1861, 1864;
    [citations].)” (Morey v. Vannucci (1998) 64 Cal.
    App. 4th 904, 912, 75 Cal. Rptr. 2d 573; see also
    People v. Toscano, supra, at p. 345, 20 Cal. Rptr. 3d
    923.)

People v. Shelton, ___ P.3d ___, 37 Cal. Rptr. 3d 354, 358
(Cal. 2006) (emphasis added) (alterations in original).

   The California Supreme Court proceeded to explain that in
resolving the ambiguous plea agreement before it, it would:
                          BUCKLEY v. TERHUNE                            2833
      consider the circumstances under which this term of
      the plea agreement was made, and the matter to
      which it relates (Civ. Code, § 1647) to determine the
      sense in which the prosecutor and the trial court (the
      promisors) believed, at the time of making it, that
      defendant (the promisee) understood it (id., § 1649).

Id. The court further noted that one interpretation of the
agreement was “reinforced by the prosecutor’s remarks at the
sentencing hearing . . . .” Id. at 359. In reaching its conclu-
sion, the court noted that it considered “the totality of the cir-
cumstances presented here.” Id.

   Thus, under California law, a judicial determination of the
parties’ expectations in a plea agreement is not confined to
reviewing the four corners of the plea agreement. A plea
agreement is not like a contract between two private parties.
Rather, in a plea agreement, the prosecutor and the defendant
agree to make certain representations to the trial judge who
retains the authority to accept or reject those representations.
See Frankel v. Bd. of Dental Examiners, 46 Cal. App. 4th
534, 551 (Cal. Ct. App. 1996). Furthermore, a plea agreement
is often, as in this case, before the trial court on at least two
occasions at which various factors that have an influence on
the agreement and the parties’ expectations may be consid-
ered. Here, the trial court first considered the plea agreement
at the change-of-plea hearing, and subsequently the trial court
considered the provisions of the plea agreement when it sen-
tenced Buckley.

   A review of the record in this case shows that the state
court reasonably determined that Buckley’s expectation was
that he would receive a 15-years-to-life sentence.1 As noted in
  1
   It is true that the California Superior Court did not specify that the plea
agreement should be interpreted pursuant to general contract terms. None-
theless, the application of those terms would not have changed that court’s
factual determination. Moreover, the state court’s factual finding that
Buckley well knew that his bargained-for sentence was 15 years to life
resolved the ambiguity in the agreement.
2834                     BUCKLEY v. TERHUNE
the majority opinion, there is some question as to what lan-
guage was in the plea agreement when Buckley signed it. The
record, however, shows that when Buckley testified in Fau-
ber’s trial in January 1988, he stated that he had pled guilty
to second-degree murder, with a penalty of 15 years to life,
in return for the District Attorney not prosecuting him with
murder in the first degree, which carried a penalty of 25 years
to life, and dropping the robbery and burglary charges. More-
over, at his subsequent sentencing hearing in March 1988, the
trial court sentenced Buckley to a prison term of 15 years to
life and a parole term of life. Buckley was represented by
counsel at the sentencing hearing and did not object to the
imposed sentence. Furthermore, the attorney who represented
Buckley in 1988 subsequently testified that he had no recol-
lection of negotiating a determinant sentence of 15 years with
the District Attorney or discussing such a sentence with Buck-
ley. It was not until 1996 that Buckley advanced the conten-
tion that his plea agreement was for 15 years. Perhaps
reasonable minds may differ on whether Buckley in 1988
knew that his plea agreement was for 15 years to life, but the
state court’s determination that he did is not “an unreasonable
determination of the facts in light of the evidence presented.”
See 28 U.S.C. § 2254(d)(2): see also Taylor, 366 F.3d at 1000
(stating that “it is not enough that we would reverse in similar
circumstances if this were an appeal from a district court deci-
sion;” instead, we must be convinced that the state court
“could not reasonably conclude that the finding is supported
by the record.”).

   Finally, I note that this factual determination is further bol-
stered by the State’s representation — not rebutted by the
majority or by Buckley — that the allegedly bargained-for
sentence of 15 years was illegal under California law.2 This
  2
   For this reason, I also disagree with the majority’s holding that Buck-
ley is entitled to specific performance of the plea agreement, as it inter-
prets the agreement. Were I to otherwise agree with the majority, I would
vacate the sentence and give Buckley an opportunity to withdraw his plea;
                          BUCKLEY v. TERHUNE                          2835
too, is part of the relevant surrounding circumstances that a
court may consider in determining the parties’ intent in enter-
ing into a plea agreement. There is nothing in the record to
suggest that the prosecutor intended or had any motive to
agree to such an illegal sentence. Similarly, there is nothing
in the record to suggest that the trial judge was not aware of
the statutory sentence for second degree murder or that he
intended to approve an illegal sentence.

   In this case, the state court — on the basis of the same evi-
dence as Buckley presented in his federal habeas petition —
determined that Buckley “well knew that the term of impris-
onment for which he was to be committed to prison for the
crime of second degree murder was 15 years to life.” Pursuant
to 28 U.S.C. § 2254(d)(2), this factual determination pre-
cludes federal habeas relief unless it is “unreasonable.” The
fact that the state court did not refer to contract law when
determining Buckley’s understanding of the plea agreement
does not make the state court’s factual determination unrea-
sonable. Accordingly, I would vacate the district court’s grant
of Buckley’s petition for a writ of habeas corpus, and deny the
petition.




thus placing both sides back in the positions they were in prior to their
entry into the plea bargain. This is not to suggest that what has transpired
since 1988 would not have a substantial impact on the parties’ subsequent
actions. Rather, my concern is that a federal court should not order the
specific performance of a plea agreement in a state court that is illegal
under state law.
