
9 Cal.4th 863 (1995)
891 P.2d 804
39 Cal. Rptr.2d 824
CHIA-LEE HSU et al., Plaintiffs and Appellants,
v.
MAHER J. ABBARA et al., Defendants and Appellants.
Docket No. S037574.
Supreme Court of California.
April 6, 1995.
*865 COUNSEL
Mantalica & Treadwell, Mark A. Treadwell and Denis White for Plaintiffs and Appellants.
Stephen Lewis for Defendants and Appellants.
OPINION
KENNARD, J.
When a contract contains a provision granting either party the right to recover attorney fees in the event of litigation on the contract, Civil Code section 1717 (hereafter section 1717) gives the "party prevailing on the contract" a right to recover attorney fees, whether or not that party is the party specified in the contract. It defines the phrase "party prevailing on the contract" as "the party who recovered a greater relief in the action on the contract," and it provides that a trial court "may also determine that there is no party prevailing on the contract for purposes of this section."
The issue we address here is whether a trial court may determine that there is no "party prevailing on the contract" when the court renders a simple, unqualified decision in favor of the defendant on the only contract claim in *866 the action. We conclude that in that situation the defendant, who is unquestionably the sole victor, is the party prevailing on the contract as a matter of law and therefore entitled to reasonable attorney fees under section 1717.

I
On June 5, 1987, defendants Maher J. and Diane Abbara (husband and wife; hereafter the Abbaras) signed an agreement with Roy Rhino (a real estate agent; hereafter Rhino) and Merrill Lynch Realty (Rhino's employer; hereafter Merrill Lynch), listing their single family home in Diamond Bar, California, for sale at a price of $299,900.
On June 8, 1987, plaintiffs Chia-Lee and Tammy Hsu (husband and wife; hereafter the Hsus) viewed the Abbaras' home in the company of their own real estate agent, Ben Lin. Later that day, using a standard real estate form, the Hsus made a written offer to purchase the home for $285,000. The form included this provision for attorney fees: "In any action between Broker, BUYER or SELLER arising out of this agreement, the prevailing party shall be entitled to reasonable attorney's fees and costs." On June 9, the Abbaras made a written counteroffer, also on a standard real estate form, at a price of $297,000, with the counteroffer to expire at 5 p.m. on June 10. The counteroffer incorporated by reference the terms and conditions of the offer, including the provision for attorney fees.
When Lin informed the Hsus of the counteroffer, they asked to see the Abbaras' house again. After their second view of the house, the Hsus told Lin they would like to raise their offer to $292,000. On the bottom of the counteroffer form, on the space provided to specify proposed amendments to the counteroffer, Lin wrote: "All terms are accepted except price to be $292,000" and "Unless the above is accepted on or before 6/10, 1987 at 11:00 AM, it shall be deemed revoked." The Hsus then signed the form. Lin told the Hsus he thought the price of $292,000 was still too low. The Hsus asked Lin to find out the lowest price the Abbaras would accept.
During the evening of June 9, 1987, Lin telephoned Rhino. Lin said $297,000 was "too high" and asked whether the Abbaras would consider a sale price between $285,000 and $297,000. Rhino advised Lin to present any new offer in writing. Lin telephoned Rhino a second time that evening to report that the Hsus were "at $292,000 and firm." Rhino told Lin he would communicate this new offer to the Abbaras the next morning.
On the morning of June 10, 1987, Rhino told the Abbaras about his conversations with Lin. The Abbaras told Rhino they would not accept *867 $292,000, and that they would "go back to asking full price" because the house had only recently been placed on the market.
That afternoon, Rhino received an envelope containing the Abbaras' written counteroffer, now bearing the signature of the Hsus. The form contained two checkboxes by which the buyers could indicate whether their acceptance of the counteroffer was unconditional or subject to proposed amendments. Neither box had been checked. The handwritten words "All terms are accepted except price to be $292,000" had been lined out and "Offer terms are accepted" was handwritten below the lined-out writing. But the document still contained the handwritten notation that it would be deemed revoked if not accepted "on or before 6/10, 1987 at 11:00 AM." The document was not accompanied by a check or other form of "good faith" deposit.
After receiving this document, Rhino telephoned the Abbaras to report that the Hsus had agreed to the counteroffer price of $297,000. The Abbaras stated that anything less than the list price was no longer acceptable. They also mentioned that it appeared they would be unable to buy a suitable replacement home. They had planned to purchase a house with a particular floor plan in a particular tract, but they had just learned there were no acceptable homes remaining for sale in that tract. Over the next few days, Rhino attempted to locate a suitable replacement home for the Abbaras, but he did not succeed. In the meantime, Rhino prepared escrow instructions for a sale at $297,000, and he delivered these instructions to an escrow agent. The Hsus signed the instructions; the Abbaras did not.
On June 18, 1987, the Abbaras sent notes to Lin and to the escrow agent stating that they would not be selling their home to the Hsus. Rhino drafted the notes and dictated them to Diane Abbara, who signed and mailed them. The notes cited the Abbaras' failure to find a replacement home, rather than a lack of agreement on price, as the reason why the Abbaras were not proceeding with the sale.
On June 22, 1987, the Hsus commenced this action against the Abbaras. Their unverified complaint alleged the formation of a contract of sale and requested specific performance of that contract. The Abbaras answered with a general denial. In 1989, after obtaining new counsel, the Abbaras cross-complained against their agents (Rhino and Merrill Lynch) seeking indemnity and damages on various theories, including negligence, breach of fiduciary duty, and breach of the listing agreement.
The action was tried to the court in March 1992. The trial was bifurcated, with trial on the complaint to be followed by trial on the cross-complaint. *868 When the Hsus rested their case, the trial court granted the Abbaras' motion for judgment on the complaint.[1] (Code Civ. Proc., § 631.8.) The trial court found that after the Abbaras had made a counteroffer at $297,000, the Hsus (through Lin's telephone conversations with Rhino) made a new offer at $292,000, which the Abbaras rejected. The trial court apparently reasoned that because the new oral offer at $292,000 extinguished the Abbaras' counteroffer at $297,000, the Hsus purported acceptance of the $297,000 counteroffer was actually another new offer, and the Abbaras "had no obligation to accept any further counteroffers or offers by the [Hsus]." Thus, the trial court concluded that no contract was ever formed.
Following the announcement of the court's ruling on the complaint, the parties stipulated that the issue of attorney fees would be "submitted to the court through written briefs."[2]
The Abbaras argued in their brief that they should be awarded attorney fees from the Hsus under section 1717 as the parties prevailing on the contract cause of action. They argued also that they should be awarded attorney fees from their agents on the cross-complaint, either under section 1717 and the attorney fee provision of the listing agreement[3] or under the "tort of another" doctrine (see Gray v. Don Miller & Associates, Inc. (1984) 35 Cal.3d 498 [198 Cal. Rptr. 551, 674 P.2d 253, 44 A.L.R.4th 763]) on the *869 theory that the agents had caused the Abbaras to incur attorney fees by their negligent or intentional misrepresentation to the Hsus that the Abbaras had accepted the Hsus' counteroffer at $297,000.[4]
The agents asserted in their reply brief that "the issue of the cross-complaint was made moot by the court's ruling on the motion for nonsuit," and that for this reason the Abbaras could recover nothing on the cross-complaint. Therefore, the agents reasoned, they should be entitled to recover their attorney fees from the Abbaras under section 1717 and the attorney fee provision in the listing agreement as the prevailing parties on the cross-complaint.[5]
For their part, the Hsus argued that they were entitled to recover their attorney fees from the Abbaras and from the Abbaras' agents. They maintained that the Abbaras' agents had negligently or intentionally misrepresented to them that a contract had been formed at a sale price of $297,000, and that the Abbaras were vicariously liable for the conduct of their agents. They claimed that the Abbaras had not informed them until long after they (the Hsus) had filed suit for specific performance that the Abbaras were claiming there had been no agreement as to price. The Hsus insisted that in so doing the Abbaras had acted inequitably and thereby provided the court with an independent ground to deny the Abbaras' request for fees and to instead award fees to the Hsus.
After receiving the parties' briefs, the trial court ruled on the issues of attorney fees and costs. The court awarded the Abbaras their costs of suit from the Hsus, but denied the Abbaras any recovery of attorney fees from the Hsus. The court provided no explanation of the ruling, which was first announced in the judgment. The judgment further provided that the Abbaras would recover nothing from the cross-defendants.
The Abbaras appealed from the portion of the judgment that denied them attorney fees. The Hsus cross-appealed from the judgment for the Abbaras *870 on the complaint. The Court of Appeal affirmed the judgment. As for the Abbaras' appeal (which is all that concerns us here), the Court of Appeal construed the judgment as an implied finding "that there was no prevailing party on the complaint for purposes of ... section 1717." Noting that it could not disturb this implied finding "unless there is clear showing of an abuse of discretion," the Court of Appeal rejected the Abbaras' contention that they were entitled to attorney fees, stating as explanation only that the Abbaras had failed "to discuss all of the pertinent facts in the record which bear on the issue of abuse of discretion."

II
(1) As a preliminary matter, we note that neither party attaches any special significance to the trial court's finding that no contract of sale was ever formed. The Hsus appear to concede that the validity or existence of the contract alleged in their complaint is not a prerequisite to an award of attorney fees under section 1717. It is now settled that a party is entitled to attorney fees under section 1717 "even when the party prevails on grounds the contract is inapplicable, invalid, unenforceable or nonexistent, if the other party would have been entitled to attorney's fees had it prevailed." (Bovard v. American Horse Enterprises, Inc. (1988) 201 Cal. App.3d 832, 842 [247 Cal. Rptr. 340]; accord, Anmaco, Inc. v. Bohlken (1993) 13 Cal. App.4th 891, 902 [16 Cal. Rptr.2d 675]; Walsh v. New West Federal Savings & Loan Assn. (1991) 234 Cal. App.3d 1539, 1547 [1 Cal. Rptr.2d 35]; Rainer National Bank v. Bodily (1991) 232 Cal. App.3d 83, 86 [282 Cal. Rptr. 926]; On v. Cow Hollow Properties (1990) 222 Cal. App.3d 1568, 1574 [272 Cal. Rptr. 535]; Alhambra Redevelopment Agency v. Transamerica Financial Services (1989) 212 Cal. App.3d 1370, 1380 [261 Cal. Rptr. 248]; North Associates v. Bell (1986) 184 Cal. App.3d 860, 865 [229 Cal. Rptr. 305]; Diamond v. John Martin Co. (9th Cir.1985) 753 F.2d 1465, 1467.)
This rule serves to effectuate the purpose underlying section 1717. As this court has explained, "[s]ection 1717 was enacted to establish mutuality of remedy where [a] contractual provision makes recovery of attorney's fees available for only one party [citations], and to prevent oppressive use of one-sided attorney's fees provisions. [Citation.]" (Reynolds Metals Co. v. Alperson (1979) 25 Cal.3d 124, 128 [158 Cal. Rptr. 1, 599 P.2d 83]; see generally, Acoba, Recovery of Attorney's Fees in Actions to Enforce Contracts: California Civil Code Section 1717 (1985) 12 Western St. U.L.Rev. 751.) The statute would fall short of this goal of full mutuality of remedy if its benefits were denied to parties who defeat contract claims by proving that they were not parties to the alleged contract or that it was never formed. To achieve its goal, the statute generally must apply in favor of the party *871 prevailing on a contract claim whenever that party would have been liable under the contract for attorney fees had the other party prevailed.

III
(2a) The Hsus contend that the trial court properly declined to award attorney fees to the Abbaras, even though the Abbaras prevailed on the Hsus' claim for specific performance of the alleged contract of sale. The Hsus rely on the portion of section 1717 stating that a trial court "may also determine that there is no party prevailing on the contract for purposes of this section." They maintain that this provision vests the trial court with broad discretion to deny attorney fees to an ostensibly prevailing party (such as the Abbaras) based on a wide variety of equitable considerations, and that the present record reveals equitable considerations sufficient to justify the trial court's decision.
In construing a statute, a court's objective is to ascertain and effectuate legislative intent. (Kimmel v. Goland (1990) 51 Cal.3d 202, 208 [271 Cal. Rptr. 191, 793 P.2d 524].) To determine legislative intent, a court begins with the words of the statute, because they generally provide the most reliable indicator of legislative intent. (Burden v. Snowden (1992) 2 Cal.4th 556, 562 [7 Cal. Rptr.2d 531, 828 P.2d 672].)
(3) We agree with the Hsus that the statutory language at issue here  stating that the trial court "may" determine that there is no party prevailing on the contract for purposes of an award of attorney fees  vests the trial court with discretion in making the prevailing party determination. But the words of the statute do not explain what considerations should guide the trial court in the exercise of this discretion. Because the words of the statute do not answer this question, we must look elsewhere for evidence of legislative intent.
Statutory ambiguities often may be resolved by examining the context in which the language appears and adopting the construction which best serves to harmonize the statute internally and with related statutes. (Woods v. Young (1991) 53 Cal.3d 315, 323 [279 Cal. Rptr. 613, 807 P.2d 455].) Here, the operative provision of section 1717 states that "[i]n any action on a contract, where the contract specifically provides that attorney's fees and costs, which are incurred to enforce that contract, shall be awarded either to one of the parties or to the prevailing party, then the party who is determined to be the party prevailing on the contract, whether he or she is the party specified in the contract or not, shall be entitled to reasonable attorney's fees in addition *872 to other costs." (Italics added.) The words "shall be entitled" reflect a legislative intent that a party prevailing on a contract receive attorney fees as a matter of right (and that the trial court is therefore obligated to award attorney fees) whenever the statutory conditions have been satisfied. This language would be incongruous if, as the Hsus contend, trial courts retained virtually unlimited discretion to deny attorney fees under section 1717 on equitable grounds.
How, then, may section 1717 be harmonized internally? In particular, how may the language of its operative provision, stating that a party prevailing on the contract "shall be entitled" to an award of attorney fees, be reconciled with the provision giving the trial court discretion to determine that there is no prevailing party? To answer this question, it is helpful to trace the history and evolution of section 1717.
As originally enacted, section 1717 provided for an award of "reasonable attorney's fees" to the "prevailing party" in "any action on a contract, where such contract specifically provides that attorney's fees and costs, which are incurred to enforce the provisions of such contract, shall be awarded to one of the parties." (Stats. 1968, ch. 266, § 1, p. 578.) It defined "prevailing party" as "the party in whose favor final judgment is rendered." (Ibid.)
In International Industries, Inc. v. Olen (1978) 21 Cal.3d 218 [145 Cal. Rptr. 691, 577 P.2d 1031], this court determined that a defendant could not recover attorney fees under section 1717 when the plaintiff voluntarily dismissed the action before trial. We agreed with previous Court of Appeal decisions holding that a voluntary dismissal is not a rendition of final judgment within the meaning of section 1717. We also found that denial of attorney fees in this situation was consistent with "sound public policy and recognized equitable considerations." (21 Cal.3d at p. 223.) Elaborating on this point, we stated:
"In Ecco-Phoenix Electric Corp. v. Howard J. White, Inc. (1969) 1 Cal.3d 266, 272 [81 Cal. Rptr. 849, 461 P.2d 33], this court rejected literal and inflexible interpretation of attorney fees clauses, pointing out that literal construction of the clause before the court would permit  contrary to sound public policy  the promisee to recover even if he was responsible for the litigation, encouraging and in fact indemnifying vexatious and frivolous litigation. Although the contract provision in that case provided for defendant's recovery of fees for any litigation, this court held that fees could be recovered only to the extent necessary to protect the defendant's rights and that where the plaintiff is partially successful, the plaintiff's liability is limited to fees for the part of the defense which was successful. Other cases have likewise recognized that the contractual provisions for attorney fees will not be inflexibly enforced and that the form of the judgment is not *873 necessarily controlling, but must give way to equitable considerations." (International Industries, Inc. v. Olen, supra, 21 Cal.3d 218, 223-224.)
The Legislature amended section 1717 in 1981. (Stats. 1981, ch. 888, § 1, p. 3399.) The amendment codified the holding of International Industries, Inc. v. Olen, supra, 21 Cal.3d 218, by adding the following language: "Where an action has been voluntarily dismissed or dismissed pursuant to a settlement of the case, there shall be no prevailing party for purposes of this section." In addition, the Legislature deleted the definition of "prevailing party" as "the party in whose favor final judgment is rendered," and provided instead that "the prevailing party shall be the party who is entitled to recover costs of suit," and that the trial court "upon notice and motion by a party, shall determine who is the prevailing party, whether or not the suit proceeds to final judgment."[6] By this provision, the Legislature appears to have intended to abrogate the holding in Samuels v. Sabih (1976) 62 Cal. App.3d 335, 340 [133 Cal. Rptr. 74], which had held that a defendant could not recover attorney fees under section 1717 if the action was dismissed for failure to prosecute. (See Elms v. Builders Disbursements, Inc. (1991) 232 Cal. App.3d 671, 673-674 [283 Cal. Rptr. 515] § 674.)
Section 1717 was again amended in 1983 (Stats. 1983, ch. 1073, § 1, p. 3785) and 1986 (Stats. 1986, ch. 785, § 1, p. 2653) in ways not pertinent here.[7]
In 1987, the Legislature amended section 1717 to its current form. (Stats. 1987, ch. 1080, § 1, p. 3648.) The Legislature replaced the term "prevailing party" with the term "party prevailing on the contract," evidently to emphasize that the determination of prevailing party for purposes of contractual attorney fees was to be made without reference to the success or failure of *874 noncontract claims. (See, e.g., On v. Cow Hollow Properties, supra, 222 Cal. App.3d 1568, 1574.) Also, the Legislature deleted the previous definition of "prevailing party" as the party entitled to recover costs, providing instead that "the party prevailing on the contract shall be the party who recovered a greater relief in the action on the contract." Finally, the Legislature added the language, central to this case, stating that the trial court "may also determine that there is no party prevailing on the contract for purposes of this section."[8]
This provision, allowing the court to find that there was no party prevailing on the contract for purposes of contractual attorney fees, was declaratory of existing law.[9] As early as 1980, in Kytasty v. Godwin (1980) 102 Cal. App.3d 762 [162 Cal. Rptr. 556], the Courts of Appeal had recognized that the results of litigation may be so equivocal as to permit or even require that no party be found to have prevailed for purposes of attorney fees under section 1717. In that case, a landowner had sued her grantor, who had retained adjoining property, to quiet title as against a claim of easement. The trial court found that the claimed easement was valid, but also that its scope was narrower than the grantor had claimed. The Court of Appeal denied a request for attorney fees under section 1717, explaining its reasoning this way:
"Finally, we are called upon to grant attorneys' fees since this action was brought by [plaintiff] under her contract of purchase. Under Civil Code section 1717, attorneys' fees are available to the prevailing party and, as expressed by the trial court, we are unable to determine who is the prevailing party, if there is one. The judgment as well as this opinion must be considered good news and bad news to each of the parties, and in good conscience we cannot say attorneys' fees should be awarded either for the *875 trial or for this appeal." (Kytasty v. Godwin, supra, 102 Cal. App.3d 762, 774.)
A different Court of Appeal reached a similar conclusion in Nasser v. Superior Court (1984) 156 Cal. App.3d 52 [202 Cal. Rptr. 552]. There, a lessee brought a declaratory relief action against the lessor to validate an option to renew and to establish the amount of rent due during the extension period. The trial court validated the option but fixed the rent at an amount substantially higher than the lessee had argued for. Given this mixed result, the Court of Appeal held that the trial court had acted properly in finding that there was no prevailing party under section 1717, rejecting the lessee's contention that section 1717, as it then read, required the trial court to designate a prevailing party. (Nasser v. Superior Court, supra, 156 Cal. App.3d at pp. 57-60.) After reviewing available legislative materials, the Court of Appeal found "no discernible intent to impose a mandatory duty to declare one prevailing party in cases where the victory and loss is [sic] evenly divided...." (Id. at p. 59, italics added.)
Since the 1987 amendment of section 1717, the appellate courts have continued to recognize the trial court's authority to determine that there is no party prevailing on the contract for purposes of contractual attorney fees, but for the most part these have also been cases in which the opposing litigants could each legitimately claim some success in the litigation. One case, for example, involved cross-actions by neighboring landowners for breach of covenants, conditions, and restrictions (CC&R's) containing an attorney fees provision. (Bankes v. Lucas (1992) 9 Cal. App.4th 365 [11 Cal. Rptr.2d 723].) Because ultimately no relief was awarded to any party under the CC&R's, the Court of Appeal found, as a matter of law, that there was no party prevailing on the contract under section 1717.[10] (Bankes v. Lucas, supra, 9 Cal. App.4th at p. 369; see also McLarand, Vasquez & Partners, Inc. v. Downey Savings & Loan Assn. (1991) 231 Cal. App.3d 1450, 1456 [282 Cal. Rptr. 828].)
As one Court of Appeal has explained, "[t]ypically, a determination of no prevailing party results when both parties seek relief, but neither prevails, or when the ostensibly prevailing party receives only a part of the relief sought." (Deane Gardenhome Assn. v. Denktas (1993) 13 Cal. App.4th 1394, 1398 [16 Cal. Rptr.2d 816].) By contrast, when the results of the litigation on *876 the contract claims are not mixed  that is, when the decision on the litigated contract claims is purely good news for one party and bad news for the other  the Courts of Appeal have recognized that a trial court has no discretion to deny attorney fees to the successful litigant. Thus, when a defendant defeats recovery by the plaintiff on the only contract claim in the action, the defendant is the party prevailing on the contract under section 1717 as a matter of law. (See, e.g., Melamed v. City of Long Beach (1993) 15 Cal. App.4th 70, 84 [18 Cal. Rptr.2d 729]; Deane Gardenhome Assn. v. Denktas, supra, 13 Cal. App.4th 1394, 1398; Elms v. Builders Disbursements, Inc., supra, 232 Cal. App.3d 671, 674-675; Manier v. Anaheim Business Center Co. (1984) 161 Cal. App.3d 503, 505-509 [207 Cal. Rptr. 508].) Similarly, a plaintiff who obtains all relief requested on the only contract claim in the action must be regarded as the party prevailing on the contract for purposes of attorney fees under section 1717. (E.g., Texas Commerce Bank v. Garamendi (1994) 28 Cal. App.4th 1234, 1247 [34 Cal. Rptr.2d 155]; Smith v. Krueger (1983) 150 Cal. App.3d 752, 757 [198 Cal. Rptr. 174].)
We are persuaded that this construction of section 1717 properly reflects and effectuates legislative intent. It is consistent with the underlying purposes of the statute  to achieve mutuality of remedy  and it harmonizes section 1717 internally by allowing those parties whose litigation success is not fairly disputable to claim attorney fees as a matter of right, while reserving for the trial court a measure of discretion to find no prevailing party when the results of the litigation are mixed.
Accordingly, we hold that in deciding whether there is a "party prevailing on the contract," the trial court is to compare the relief awarded on the contract claim or claims with the parties' demands on those same claims and their litigation objectives as disclosed by the pleadings, trial briefs, opening statements, and similar sources. The prevailing party determination is to be made only upon final resolution of the contract claims and only by "a comparison of the extent to which each party ha[s] succeeded and failed to succeed in its contentions." (Bank of Idaho v. Pine Avenue Associates (1982) 137 Cal. App.3d 5, 15 [186 Cal. Rptr. 695].)
(2b) Here, the judgment was a "simple, unqualified win" (Deane Gardenhome Assn. v. Denktas, supra, 13 Cal. App.4th 1394, 1398) for the Abbaras on the only contract claim between them and the Hsus. In this situation, the trial court had no discretion to deny the Abbaras their attorney fees under section 1717 by finding, expressly or impliedly, that there was no party prevailing on the contract. The record contains no substantial evidence to support such a finding.
*877 The Hsus cite language in this court's decision in International Industries, Inc. v. Olen, supra, 21 Cal.3d 218, 224, stating that "contractual provisions for attorney fees will not be inflexibly enforced" and that "the form of the judgment is not necessarily controlling, but must give way to equitable considerations." We agree that in determining litigation success, courts should respect substance rather than form, and to this extent should be guided by "equitable considerations." For example, a party who is denied direct relief on a claim may nonetheless be found to be a prevailing party if it is clear that the party has otherwise achieved its main litigation objective. (See, e.g., Lewis v. Alpha Beta Co. (1983) 141 Cal. App.3d 29 [189 Cal. Rptr. 840]; see also National Computer Rental, Ltd. v. Bergen Brunswig Corp. (1976) 59 Cal. App.3d 58, 63 [130 Cal. Rptr. 360] [defendant awarded fees under section 1717 because it prevailed on the only disputed claim, even though plaintiff obtained judgment on undisputed claims].) But when one party obtains a "simple, unqualified win" on the single contract claim presented by the action, the trial court may not invoke equitable considerations unrelated to litigation success, such as the parties' behavior during settlement negotiations or discovery proceedings, except as expressly authorized by statute. (See, e.g., Deane Gardenhome Assn. v. Denktas, supra, 13 Cal. App.4th 1394, 1398-1399 [trial court improperly relied on party's obstreperous behavior and uncompromising litigation stance to find there was no prevailing party]; Bruckman v. Parliament Escrow Corp. (1987) 190 Cal. App.3d 1051, 1059 [235 Cal. Rptr. 813] [stating that party's failure to offer to compromise did not affect that party's right to attorney fees under section 1717].) To admit such factors into the "prevailing party" equation would convert the attorney fees motion from a relatively uncomplicated evaluation of the parties' comparative litigation success into a formless, limitless attack on the ethics and character of every party who seeks attorney fees under section 1717. We find no evidence that the Legislature intended that the prevailing party determination be made in this way.

CONCLUSION
When a defendant obtains a simple, unqualified victory by defeating the only contract claim in the action, section 1717 entitles the successful defendant to recover reasonable attorney fees incurred in defense of that claim if the contract contained a provision for attorney fees. The trial court has no discretion to deny attorney fees to the defendant in this situation by finding that there was no party prevailing on the contract. Because the Abbaras successfully defended the only contract claim in their litigation with the Hsus, the Abbaras were, as a matter of law, the parties prevailing on the contract. Accordingly, the trial court erred in denying them attorney fees under section 1717.
*878 The judgment of the Court of Appeal is reversed and the matter is remanded for further proceedings consistent with this opinion.
Lucas, C.J., Mosk, J., Arabian, J., Baxter, J., George, J., and Werdegar, J., concurred.
NOTES
[1]  Counsel for the cross-defendants Rhino and Merrill Lynch stated that his clients joined in the Abbaras' motion for judgment, and the court's minute order states that the court granted the "joint motion." But the cross-defendants were not parties to the main action, and thus had no standing to move for judgment in that action. Nor can their motion be construed as a motion for judgment on the cross-complaint. All indications in the record are that cross-defendants were attempting to join the Abbaras' motion, rather than making their own separate motion directed to a different action. Moreover, a motion for judgment on the cross-complaint would have been premature because trial on the cross-complaint had not yet begun (and in fact was never held).
[2]  The only record of the stipulation is the court's minute order, which recites it in these terms: "Counsel stipulate that the issue of attorney fees, on the cross-complaint, may be submitted to the court through written briefs. Counsel for Defendants Abbara shall have until May 15, 1992 to submit their brief, and the reply briefs of plaintiffs and of cross-defendant Merrill Lynch shall be submitted by June 15, 1992."

The purpose of the italicized reference to the cross-complaint is unclear. Although the stipulation as worded seems to confine the issue of attorney fees to the cross-complaint, this would be inconsistent with the provision for briefing by the Hsus, who were not parties to the cross-complaint. At most, it appears that the briefs were intended to include any claim of attorney fees under either the complaint or the cross-complaint, even though the parties had not yet tried the cross-complaint, nor had the court ruled upon it. In any event, the order of the briefing (opening brief by the Abbaras, with reply briefs by the Hsus and the agents) indicates that the Abbaras were regarded as the moving parties on the issue of attorney fees.
[3]  The argument ignored, among other things, that the cross-complaint was not a contract action for breach of the listing agreement but rather a tort action, and thus section 1717 did not apply. (See, e.g., Stout v. Turney (1978) 22 Cal.3d 718, 730 [150 Cal. Rptr. 637, 586 P.2d 1228]; Super 7 Motel Associates v. Wang (1993) 16 Cal. App.4th 541, 549 [20 Cal. Rptr.2d 193].)
[4]  Unless the parties stipulate otherwise, a claim for attorney fees under the "tort of another" doctrine may not be asserted by post-trial motion but rather must be pleaded and proved to the trier of fact. (Brandt v. Superior Court (1985) 37 Cal.3d 813, 819 [210 Cal. Rptr. 211, 693 P.2d 796]; Vacco Industries, Inc. v. Van Den Berg (1992) 5 Cal. App.4th 34, 56 [6 Cal. Rptr.2d 602].) Accordingly, the Abbaras' claim for attorney fees under the "tort of another doctrine" ordinarily should have been asserted through trial of their cross-complaint, and could be asserted by motion only by construing the parties' ambiguous stipulation (see fn. 2, ante) as so permitting.
[5]  See footnote 3, ante.
[6]  The 1981 amendment also added this paragraph to section 1717:

"Where the defendant alleges in his or her answer that he or she tendered to the plaintiff the full amount to which he or she was entitled, and thereupon deposits in court, for the plaintiff, the amount so tendered, and the allegation is found to be true, then the defendant is deemed to be a prevailing party within the meaning of this section." (Stats. 1981, ch. 888, § 1, p. 3400.)
[7]  The 1983 amendment added a paragraph that reads:

"Where a contract provides for attorney's fees, as set forth above, such provision shall be construed as applying to the entire contract, unless each party was represented by counsel in the negotiation and execution of the contract, and the fact of that representation is specified in the contract." (Stats. 1983, ch. 1073, § 1, p. 3785.)
The 1986 amendment added this paragraph:
"Where a deposit has been made pursuant to this section, the court shall, on the application of any party to the action, order the deposit to be invested in an insured, interest-bearing account. Interest on the amount shall be allocated to the parties in the same proportion as the original funds are allocated." (Stats. 1986, ch. 785, § 1, p. 2654.)
[8]  In relevant part, section 1717 now reads:

"(a) In any action on a contract, where the contract specifically provides that attorney's fees and costs, which are incurred to enforce that contract, shall be awarded either to one of the parties or to the prevailing party, then the party who is determined to be the party prevailing on the contract, whether he or she is the party specified in the contract or not, shall be entitled to reasonable attorney's fees in addition to other costs.
". . . . . . . . . . . . . . . . . . . . . . . . . . . .
"Reasonable attorney's fees shall be fixed by the court, and shall be an element of the costs of suit.
". . . . . . . . . . . . . . . . . . . . . . . . . . . .
"(b)(1) The court, upon notice and motion by a party, shall determine who is the party prevailing on the contract for purposes of this section, whether or not the suit proceeds to final judgment. Except as provided in paragraph (2), the party prevailing on the contract shall be the party who recovered a greater relief in the action on the contract. The court may also determine that there is no party prevailing on the contract for purposes of this section.
". . . . . . . . . . . . . . . . . . . . . . . . . . . ."
[9]  Neither party has brought to our attention any legislative committee reports or other legislative materials explaining the purpose of this provision. On our own initiative, we have consulted these materials, but we have found nothing relevant to our inquiry here.
[10]  When there are cross-actions on a contract containing an attorney fees provision, and no relief is awarded in either action, a trial court is not obligated to find that there is no party prevailing on the contract for purposes of section 1717. If the court concludes that the defendant's cross-action against the plaintiff was essentially defensive in nature, it may properly find the defendant to be the party prevailing on the contract.
