
232 Cal.App.3d 83 (1991)
282 Cal. Rptr. 926
RAINIER NATIONAL BANK, Plaintiff and Respondent,
v.
MERRILL G. BODILY et al., Defendants and Appellants.
Docket No. B052530.
Court of Appeals of California, Second District, Division Two.
July 11, 1991.
*84 COUNSEL
Reifman, Altman, Sherman & Weiner and Bernard L. Weiner for Defendants and Appellants.
Besser & Chapin, Robert S. Besser and Christopher Chapin for Plaintiff and Respondent.
OPINION
NOTT, J.
Merrill D. Bodily and Tawna Bodily appeal from a denial of their motion for attorney's fees. We reverse with directions.


*85 FACTS
Respondent Rainier National Bank (Rainier) obtained a judgment in the State of Washington against the Bodilys on the basis that they were guarantors of a promissory note.
The Washington judgment was entered on May 12, 1988, and provided for principal and interest in the amount of $63,866.42, plus "... attorney's fees and costs to be determined pursuant to the terms of the personal guaranty executed by defendants...."
On July 29, 1988, the Washington court awarded Rainier $6,878.25 for attorney's fees and costs, making a grand total due of $70,744.67. Rainier applied under Code of Civil Procedure section 1710.10 et seq. for that exact amount to be entered as a judgment in California, and also sought newly accrued interest and costs.
After Rainier domesticated the judgment in California in late 1989, the Bodilys moved to have it vacated. At the conclusion of an evidentiary hearing, the trial court found that the Bodilys did not sign the guaranty nor did the State of Washington have jurisdiction over them and thereby granted the motion to vacate on May 17, 1990.
On appeal, we affirmed the trial court in a decision filed on April 10, 1991. On June 21, 1990, the Bodilys filed a motion in the trial court for attorney's fees, which was denied.

ISSUE
The sole question is whether the Bodilys are entitled to attorney's fees under Civil Code section 1717.

DISCUSSION
The trial court refused to award the Bodilys attorney's fees, reasoning the action by Rainier was on a judgment, not on a contract, and was thus outside the provisions of Civil Code section 1717. We disagree.
Civil Code section 1717, subdivision (a) states in pertinent part: "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 *86 the party specified in the contract or not, shall be entitled to reasonable attorney's fees in addition to other costs."
(1) Under Civil Code section 1717, the prevailing party is entitled to attorney's fees even when it wins on the grounds that the contract is inapplicable, invalid, unenforceable or nonexistent, so long as the party pursuing the lawsuit 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]; On v. Cow Hollow Properties (1990) 222 Cal. App.3d 1568, 1574 [272 Cal. Rptr. 535].) The rationale is that Civil Code section 1717 is guided by equitable principles, including mutuality of remedy, and it would be inequitable to deny attorney's fees to one who successfully defends, simply because the initiating party filed a meritless case. (Reynolds Metals Co. v. Alperson (1979) 25 Cal.3d 124, 128-129 [158 Cal. Rptr. 1, 599 P.2d 83]; Jones v. Drain (1983) 149 Cal. App.3d 484, 489 [196 Cal. Rptr. 827].)
(2) Despite Rainier's argument that the Washington judgment is not a contract within the provisions of Civil Code section 1717, we believe that the original contract action instituted by Rainier, albeit a contract on which the Bodilys were found to be not liable, controls under section 1717. It is without question that: (1) the purported guaranty provided for attorney's fees in the event of a legal action to enforce its terms; (2) Rainier was awarded attorney's fees by the Washington court; (3) Rainier attempted to domesticate the entire Washington judgment; and (4) the Bodilys are now the prevailing party. Had Rainier initiated the litigation in California, it is indisputable that the Bodilys would be entitled to an award of attorney's fees under the authority of the previously cited cases. It matters little to the Bodilys' pocketbook whether their attorney was employed to resist an action initially filed in California or to set aside a sister state judgment. Rainier's argument also overlooks the fact that it actually received an award of attorney's fees which it tried to enforce. To disallow attorney's fees in this factual situation would reward Rainier for selecting an improper forum and would be contrary to logic and to the spirit of Civil Code section 1717.
Rainier also asserts that it was not entitled to obtain attorney's fees for its efforts in entering the judgment in California, and thus there is no mutuality of remedy for the Bodilys to recover fees. Since we have held that the basis of recovery of attorney's fees is the underlying contract and not the judgment, we need not address that issue. (Spellis v. Lawn (1988) 200 Cal. App.3d 1075, 1079 [246 Cal. Rptr. 385].)


*87 DISPOSITION
The ruling denying attorney's fees is reversed. The matter is remanded to the trial court for a hearing under Civil Code section 1717 to determine the amount of the award in favor of the Bodilys for attorney's fees incurred at the trial court and for both appeals. Appellants shall recover costs on appeal.
Gates, Acting P.J., and Fukuto, J., concurred.
