
46 Cal.App.4th 1794 (1996)
ALLSTATE INSURANCE COMPANY, Plaintiff and Respondent,
v.
DENNIS J. LOO, Defendant and Appellant.
Docket No. A071266.
Court of Appeals of California, First District, Division Four.
July 2, 1996.
*1796 COUNSEL
John M. Walker for Defendant and Appellant.
Bolinger, Morse & Sloan and William B. Sloan for Plaintiff and Respondent.
OPINION
POCHE, J.
In this case we consider whether a lessor who prevails in an action in subrogation brought by his lessee's property insurer is entitled to recover attorney fees under a provision in the lease.

BACKGROUND
Allstate insureds Tony and Eleanor Dudley were tenants in an apartment building owned by Dennis J. Loo. After their personal property was destroyed in a fire in the apartment building, they filed a claim with their insurer. After paying the claim Allstate Insurance Company commenced the instant action in subrogation against Loo, asserting causes of action for negligence, failure to disclose a latent defect, and breach of an implied warranty of habitability.
Loo successfully moved for summary judgment. Following entry of judgment, Loo filed a "Motion to Determine Prevailing Party and to Fix Amount of Attorney Fees as Costs in Contract Action," attaching a copy of the residential lease agreement he had with the Dudleys. The lease contained a *1797 provision authorizing a "reasonable attorney's fee" to the prevailing party "In any legal action brought by either party to enforce the terms hereof or relating to the demised premises...." Allstate opposed the motion, arguing Loo was not entitled to rely on the attorney fees provision in the lease because Allstate's action against Loo was based in tort, not contract. The trial court gave a different reason for denying Loo's request for attorney fees: "Neither party [pleaded] the existence of a contract containing the provision for attorney's fees." Thereafter, the court took the matter under submission and issued a final ruling denying the motion. This timely appeal by Loo followed.

REVIEW

A. Attorney Fees as an Element of Costs

(1) The trial court concluded that a party seeking to recover attorney fees pursuant to a contractual provision must plead entitlement to attorney fees as an item of damages in order to recover them in California. That is no longer correct.
Under Code of Civil Procedure section 1033.5, subdivision (a)(10), attorney fees, when authorized by contract, statute, or law, are recoverable as an element of costs. The Legislature has further detailed the procedure by which attorney fees as costs may be fixed: upon a noticed motion. (Code Civ. Proc., § 1033.5, subd. (c)(5); Cal. Rules of Court, rule 870.2.)
The trial court's ruling that attorney fees must be pleaded as an item of damages is understandable. Prior to 1990 it was not entirely clear what the proper method was to obtain an award of attorney fees. In particular, there was no agreement about whether such an award should be claimed as an element of damages or as an item of costs. (See, e.g., Bankes v. Lucas (1992) 9 Cal. App.4th 365, 370 [11 Cal. Rptr.2d 723]; Genis v. Krasne (1956) 47 Cal.2d 241, 246 [302 P.2d 289]; T.E.D. Bearing Co. v. Walter E. Heller & Co. (1974) 38 Cal. App.3d 59, 63 [112 Cal. Rptr. 910].) To end this confusion the Legislature enacted Code of Civil Procedure section 1033.5 and declared: "The Legislature finds and declares that there is great uncertainty as to the procedure to be followed in awarding attorney's fees where entitlement thereto is provided by contract to the prevailing party. It is the intent of *1798 the Legislature in enacting this act to confirm that these attorney's fees are costs which are to be awarded only upon noticed motion, except where the parties stipulate otherwise or judgment is entered by default." (Stats. 1990, ch. 804, § 2, p. 3552; see also Jue v. Patton (1995) 33 Cal. App.4th 456, 460-461 [39 Cal. Rptr.2d 364].) Thus, the trial court's ruling is wrong.

B. Tort v. Contract

(2a) Allstate suggests an alternative basis to support the trial court's ruling: Loo is not entitled to recover attorney fees under the lease provision because each of the causes of action asserted was in tort, not contract.
The initial fatal problem with this contention is that the facts do not fit. Allstate did assert a contractual cause of action: breach of the implied warranty of habitability. (Quevedo v. Braga (1977) 72 Cal. App.3d Supp. 1, 7-8 [140 Cal. Rptr. 143].)
The second fatal defect of the argument is that it assumes that if Allstate had sued only in tort the contractual provision for attorney fees would not apply. As the case law makes clear, the test is not whether the cause of action sounds in tort or contract. Instead, the sole question is the intent of the parties: did they intend to authorize the prevailing party to recover its attorney fees for a tort cause of action. (Lerner v. Ward (1993) 13 Cal. App.4th 155, 160-161 [16 Cal. Rptr.2d 486]; Xuereb v. Marcus & Millichap, Inc. (1992) 3 Cal. App.4th 1338, 1342-1343 [5 Cal. Rptr.2d 154].) The answer to that question depends upon the language of the agreement.
For example, in Xuereb v. Marcus & Millichap, Inc., supra, 3 Cal. App.4th 1338, the purchase agreement provided: "`Attorneys' Fees: If this Agreement gives rise to a lawsuit or other legal proceeding between any of the parties hereto, including Agent, the prevailing party shall be entitled to recover actual court costs and reasonable attorneys' fees in addition to any other relief to which such party may be entitled.'" (At p. 1340.) In reviewing that language, Division Three of this court had no hesitation in concluding that it was broad enough to include an action based in tort. (Id. at pp. 1342-1343.)
A slightly different provision was reviewed in Lerner v. Ward, supra, 13 Cal. App.4th 155. There a purchase agreement permitted the prevailing party to recover attorney fees "`[i]n any action or proceeding arising out of this agreement....'" (Id. at pp. 158-159.) The Court of Appeal found this provision broad enough to encompass any action or proceeding arising out of the agreement, including an action for fraud. (At p. 160.)
*1799 The provision at hand is very similar to the one reviewed in Lerner. It reads: "ATTORNEY'S FEES: In any legal action brought by either party to enforce the terms hereof or relating to the demised premises, the prevailing party shall be entitled to all costs incurred in connection with such action, including a reasonable attorney's fee." In our view, this provision encompasses any action  whether in contract or in tort  which relates to the leased premises. Each of the causes of action Allstate set forth in its complaint meets this criterion.
For these reasons, the trial court's ruling cannot be sustained on the theory that the nature of the claims advanced here did not fall within the terms of the attorney fees provision.

C. Subrogation

Allstate's second alternative basis to support the judgment is the argument that a insurer/subrogee does not assume an insured/subrogor's contractual liability for attorney fees. Again, Allstate is incorrect.
(3) An insurer/subrogee paying for a loss has the right to pursue its insured's rights and remedies against the third party causing the loss. (Continental Cas. Co. v. Phoenix Constr. Co. (1956) 46 Cal.2d 423, 429 [296 P.2d 801]; Fireman's Fund Ins. Co. v. Maryland Casualty Co. (1994) 21 Cal. App.4th 1586, 1595-1596 [26 Cal. Rptr.2d 762].) In the action for subrogation the insurer as subrogee stands in the shoes of the insured/subrogor. (Suburban Motors, Inc. v. State Farm Mut. Auto. Ins. Co. (1990) 218 Cal. App.3d 1354, 1357 [268 Cal. Rptr. 16].) When standing in the insured's shoes as the analogy indicates, the insurer has no greater rights than the insured would have, and for that reason is subject to the same defenses assertable against the insured/subrogor. (E.g., Liberty Mut. Ins. Co. v. Fales (1973) 8 Cal.3d 712, 717 [106 Cal. Rptr. 21, 505 P.2d 213]; Fireman's Fund Ins. Co. v. Maryland Casualty Co., supra, 21 Cal. App.4th at p. 1596; Bright v. American Termite Control Co. (1990) 220 Cal. App.3d 1464, 1469 [269 Cal. Rptr. 793].)
(2b) An excellent example of this principle in action in the context of contractual attorney fees is Rushing v. Intern. Aviation Underwriters (Tex.Civ.App. 1980) 604 S.W.2d 239. There defendant leased an aircraft from Hi-Performance Aviation which he damaged upon landing. The insurer of the aircraft, International Aviation Underwriters, paid for the cost of repairs under its policy with Hi-Performance Aviation, then brought an action in subrogation against the defendant-lessee to recover its loss. The trial court entered judgment for the insurer/subrogee on its negligence claim, but refused to award attorney fees. (At pp. 240-241.)
*1800 The basis of the insurer/subrogee's claim for attorney fees was a provision in the lease agreement between Hi-Performance and the defendant-lessee which gave the prevailing party the right to recover reasonable attorney fees in a suit arising out of the rental agreement or out of the use of the aircraft. (Rushing v. Intern. Aviation Underwriters, supra, 604 S.W.2d at p. 243.) The insurer argued that subrogation entitled it to all the rights held by the insured under the lease, including the contractual right as prevailing party to recover its attorney fees, and the Texas Court of Appeal agreed: "Under the general rule, an insurer bringing suit in a subrogation action receives pro tanto the rights of its insured to the extent of payments made under the insurance contract. [Citations.] The question before us is whether [the insurance company], suing on a subrogation theory, succeeds to the contractual right of its insured to recover attorney's fees. The insured expended none and thus, none were paid to the insured under the insurance contract. Rather, the attorney's fees were directly incurred by the [insurance company]. We hold that the insurer may recover attorney's fees in a subrogation action where the insured would have been entitled to attorney's fees if it had prosecuted the suit." (At pp. 243-244.)
Thus, under Rushing, had Allstate prevailed against Loo, it would have succeeded to the rights of the insured/subrogor to recover a reasonable attorney fee. We have been offered no reason in law or logic why the converse should not also be true. Loo's obligation to defend against the action was the same irrespective of the identity of the plaintiff: the lessee or the lessee's subrogee. We therefore hold that Loo, as the prevailing party, is entitled to assert his contractual right to recover reasonable attorney fees in the subrogation action.
Allstate argues that the rule we announce today is bad social policy: "To allow counterclaims against the subrogated insurer means that the insurer's risk depends on factors that are unrelated to the risks for which it earned premiums." As we have explained in part A, ante, recovery of attorney fees is not accomplished by counterclaim: it is an item of costs which has been agreed to by contract. (Code Civ. Proc., § 1033.5, subd. (a)(1).) Nor does our ruling increase any risk to insurers. In this case the risk the insurer undertook to insure against was the risk of fire damage to personal property of its insureds. The insurer lost that risk and paid its policyholders. Nothing in our decision increases or decreases that risk. After making payment the insurer had a decision to make: whether to sue the owner of the building in which the fire occurred. The insurer decided to do that but lost. We assume that the decision to so litigate was intelligently made after weighing the risks that all those who instigate litigation face. That list includes the risk of not prevailing which includes the risk of bearing all of the cost of the litigation  especially in a case in which there is a contract providing for the payment of the prevailing party's attorney fees.
*1801 Finally, Allstate also urges our holding will discourage insurance companies from pursuing their subrogation rights. We doubt it. But what we do not doubt is this: the presence of an attorney fees provision in a contract discourages  and is intended to discourage  the filing of lawsuits between the parties premised on weak legal positions. If the risk of being liable to pay attorney fees to the opposing side discourages a subrogee from pursuing a weak subrogation claim, then a valid social policy has been advanced by our holding today.
The order denying Loo's motion to recover attorney fees is reversed, and the cause is remanded for further proceedings consistent with the views expressed herein. Loo to recover costs on appeal.
Anderson, P.J., and Hanlon, J., concurred.
On August 1, 1996, the opinion was modified to read as printed above.
