On claims to which Civ. Code 1717 applies (claims on a contract), the statute’s definition of “prevailing party” supersedes any definition of that term in the parties’ contract. In applying the Hsu v. Abbara (1995) 9 Cal.4th 863 test of prevailing party, the trial court may not consider settlement offers the parties have made either informally or under CCP 998 (unless a party rejected a 998 offer that was more favorable to that party than the ultimate judgment). If a defendant concedes it owes some money to the plaintiff, it can shield itself from liability for attorney fees by tendering to the plaintiff the amount of admitted liability, thereupon depositing that sum in court, and so alleging in its answer. That statutory mechanism is exclusive. Conceding liability by other means does not prevent liability for attorney fees if the plaintiff prevails, nor can a concession of partial liability by other means turn the defendant into the prevailing party when the plaintiff recovers some amount on its breach of contract claim.