Brooks Insurance Agency (“the agency”); Sidney Brooks, its agent; and Nationwide Mutual Insurance Company and Nationwide Mutual Fire Insurance Company (collectively “Nationwide”) petition this Court for a writ of mandamus directing the Jefferson Circuit Court to vacate its order denying their motion to dismiss, pursuant to § 6-5-440, Ala.Code 1975 (“the abatement statute”), and Rule 13(a), Ala. R. Civ. P. (“the compulsory-counterclaim rule”), the action filed by Guster Law Firm, LLC, and Guster Properties, LLP (collectively “Guster”), against them. We grant the petition in part, deny it in part, and issue the writ.
I. Factual Background and Procedural History
Guster made a claim for a fire loss under commercial property policies issued to it by Nationwide. In April 2011, Nationwide filed a declaratory-judgment action in the United States District Court for the Northern District of Alabama (“the federal court”), requesting that the federal court determine the rights and obligations under the insurance policies it had issued to Gus-ter. Guster answered and asserted compulsory counterclaims against Nationwide, including bad-faith failure to pay an insurance claim and breach of contract, among others. On November 10, 2011, Guster deposed Brooks in the federal-court action. The agency and Brooks were never joined as parties to the federal-court action.
On June 11, 2012, Guster filed a lawsuit in the Jefferson Circuit Court (“the state court”), alleging against the agency, Brooks, and Nationwide negligent/wanton failure to provide insurance coverage; misrepresentation; suppression and concealment; and negligent/wanton failure to train. The agency, Brooks, and Nationwide moved to dismiss the state-court action on the ground that the action violated the abatement statute, which prohibits a party from prosecuting two actions simultaneously in different courts if the claims alleged in each action arose from the same underlying operative facts, and the compulsory-counterclaim rule, which requires a party to file as a counterclaim in an opposing party’s action any factually related claim against the opposing party that arises out of the transaction or occurrence that is the subject matter of the opposing party’s action. The trial court summarily denied the motion to dismiss on October 1, 2012. The agency, Brooks, and Nation*708wide then petitioned this Court for mandamus relief.
II. Standard of Review
This Court has considered petitions for a writ of mandamus to review orders denying motions to dismiss based on the abatement statute, see Ex parte J.E. Estes Wood Co., 42 So.3d 104 (Ala.2010), and the compulsory-counterclaim rule, see Little Narrows, LLC v. Scott, 1 So.3d 973 (Ala.2008). “ ‘[A] writ of mandamus is an extraordinary remedy, which requires the petitioner to demonstrate a clear, legal right to the relief sought, or [that the trial court exceeded its] discretion.’ Ex parte Palm Harbor Homes, Inc., 798 So.2d 656, 660 (Ala.2001)." Ex parte Compass Bank, 77 So.3d 578, 581 (Ala.2011). “ ‘When the facts underlying a motion filed pursuant to § 6-5-440 are undisputed, as is the case here, our review of the application of the law to the facts is de novo. Greene v. Town of Cedar Bluff, 965 So.2d 773, 779 (Ala.2007).’ Ex parte Metropolitan Prop. & Cas. Ins. Co., 974 So.2d 967, 969 (Ala.2007).” Clark v. Wells Fargo Bank, N.A., 24 So.3d 424, 426 (Ala.2009). “1 “The burden of establishing a clear legal right to the relief sought rests with the petitioner.’” Ex parte Dangerfield, 49 So.3d 675, 680 (Ala.2010) (quoting Ex parte Metropolitan Prop. & Cas. Ins. Co., 974 So.2d 967, 972 (Ala.2007)).” Ex parte McNeese Title, LLC, 82 So.3d 670, 673 (Ala.2011).
III. Analysis
The agency, Brooks, and Nationwide argue that the state court erred when it denied their motion to dismiss based on the abatement statute and the compulsory-counterclaim rule, because, they argue, the claims filed in the state court involve the same cause and the same opposing parties as the claims filed in the federal court and because, they argue, Guster’s claims in the state court are compulsory counterclaims in the action in the federal court.
The abatement statute provides:
“No plaintiff is entitled to prosecute two actions in the courts of this state at the same time for the same cause and against the same party. In such a case, the defendant may require the plaintiff to elect which he will prosecute, if commenced simultaneously, and the pen-dency of the former is a good defense to the latter if commenced at different times.”
§ 6-5-440, Ala. Code 1975. This Court has explained:
“[Section 6-5-440], by its plain language, forbids a party from prosecuting two actions for the ‘same cause’ and against the ‘same party.’ This Court has previously held that an action pending in a federal court falls within the coverage of this Code section:
“ ‘ “The phrase ‘courts of this state,’ as used in § 6-5-440, includes all federal courts located in Alabama. This Court has consistently refused to allow a person to prosecute an action in a state court while another action on the same cause and against the same parties is pending in a federal court in this State.” ’ ”
Ex parte Norfolk Southern Ry., 992 So.2d 1286, 1289 (Ala.2008) (quoting Ex parte University of South Alabama Found., 788 So.2d 161, 164 (Ala.2000), quoting in turn Weaver v. Hood, 577 So.2d 440, 442 (Ala.1991)). The application of the abatement statute “is guided by ‘whether a judgment in one suit would be res judicata of the other.’ ” Chiepalich v. Coale, 36 So.3d 1, 3 (Ala.2009) (quoting Sessions v. Jack Cole Co., 276 Ala. 10, 12, 158 So.2d 652, 654-55 (1963)). “Where there is no question as to the jurisdiction of the court or as to the identity of the parties, the test for deter-*709raining [the applicability of the doctrine of res judicata] is whether the issues in the two suits are the same and whether the same evidence would support a recovery in both suits.” Sessions v. Jack Cole Co., 276 Ala. at 13, 158 So.2d at 655; see also Equity Res. Mgmt., Inc. v. Vinson, 723 So.2d 634, 637 (Ala.1998) (holding that for res judicata purposes the cause of action is the same when “substantially the same evidence would support a recovery in both actions”). “A question presented to determine whether a party has run afoul of [the abatement statute] is whether the claim presented in the second action is a compulsory counterclaim in the first action.” Ex parte J.C. Duke & Assocs., Inc., 4 So.3d 1092, 1094 (Ala.2008).
In Ex parte Breman Lake View Resort, L.P., 729 So.2d 849, 851 (Ala.1999), this Court applied the abatement statute in a case where the issue involved was whether the claim asserted in the later filed action was a compulsory counterclaim in the first-filed action:
“[T]he obligation imposed on a defendant under Rule 13(a), Ala. R. Civ. P., to assert compulsory counterclaims, when read in conjunction with § 6-5^440, Ala. Code 1975, which prohibits a party from prosecuting two actions for the same cause and against the same party, is tantamount to making the defendant with a compulsory counterclaim in the first action a ‘plaintiff in that action (for purposes of § 6-5-440) as of the time of its commencement. See, e.g., Ex parte Parsons & Whittemore Alabama Pine Constr. Corp., 658 So.2d 414 (Ala.1995); Penick v. Cado Systems of Cent. Alabama, Inc., 628 So.2d 598 (Ala.1993); Ex parte Canal Ins. Co., 534 So.2d 582 (Ala.1988). Thus, the defendant subject to the counterclaim rule who commences another action has violated the prohibition in § 6-5-440 against maintaining two actions for the same cause. We affirm the general rule expressed in these cases; to do otherwise would invite waste of scarce judicial resources and promote piecemeal litigation.”
The compulsory-counterclaim rule provides:
“A pleading shall state as a counterclaim any claim which at the time of serving the pleading the pleader has against any opposing party, if it arises out of the transaction or occurrence that is the subject matter of the opposing party’s claim and does not require for its adjudication the presence of third parties of whom the court cannot acquire jurisdiction.”
Rule 13(a), Ala. R. Civ. P. (emphasis added). This Court has held that the compulsory-counterclaim rule, when read in conjunction with the abatement statute, makes the defendant with a compulsory counterclaim in the first-filed action a plaintiff in that action for purposes of the abatement statute. See Ex parte Breman Lake View Resort, L.P., 729 So.2d at 851. “Thus, the defendant subject to the [compulsory-]counterclaim rule who commences another action has violated the prohibition in [the abatement statute] against maintaining two actions for the same cause.” Id.
Although the causes of action in the federal court and the state court arose out of the same transaction or occurrence and are thus -related, Guster’s claims against the agency and-Brooks were not compulsory counterclaims in the. federal declaratory-judgment action because the agency and Brooks were not “opposing parties]” in the federal action. Little Narrows, LLC v. Scott, 1 So.3d at 978-79. In Little Narrows, this Court directly addressed the scope of the term “opposing party” as used in the compulsory-counterclaim rule. We limited the definition to those parties for*710mally named as parties in the action. Id. at 977-79. It is undisputed that the agency and Brooks were not “parties” in the action in the federal court. Because the agency and Brooks were not parties in the federal-court action, any factually related claims Guster might have against them are not compulsory counterclaims that must be asserted in that action. Accordingly, Gus-ter was free to assert its claims against the agency and Brooks in a separate action in any appropriate venue, as it did in the state court, without violating the abatement statute. The agency and Brooks have not shown that they have a clear legal right to the dismissal of the state-court action as to them, and the state court did not err in denying the motion to dismiss as to them.
We now turn to the motion to dismiss as to Nationwide. The standard for deciding whether two actions may proceed in different courts is similar to the standard applied for determining the applicability of the doctrine of res judicata; that is, whether the issues in the two actions are the same and whether the same evidence would support a recovery in both actions. See Sessions v. Jack Cole Co., supra. The complaint filed in the federal court arises from insurance policies issued to Guster by Nationwide, the investigation by Nationwide into Guster’s fire-loss claim made under those policies, and Nationwide’s refusal to pay the fire-loss claim without a declaration of the rights of the parties under the issued polices, all actions and inactions of Nationwide that occurred after Nationwide had issued certain policies of insurance to Guster. The complaint filed in the state court asserted several theories of recovery, all of which arise from events that happened before or around the same time that the insurance policies were issued to Guster. Nevertheless, whether the claims asserted by Nationwide in the federal court or the claims asserted by Guster in the state court complain of actions before or after Nationwide issued the insurance policies, all the claims in both the federal court and the state court arise from the same facts and circumstances — Nationwide’s issuance of the insurance policies to Guster and its handling of Guster’s fire-loss claim. Accordingly, the abatement statute mandates that the claims against Nationwide in Guster’s complaint filed in the state court be dismissed. Nationwide has shown that it has a clear legal right to an order dismissing the state-court action against it and that the state court erred in denying the motion to dismiss as to it.
IV. Conclusion
Based on the foregoing, we conclude that the agency and Brooks have not shown a clear legal right to the dismissal of Guster’s claims against them in the state-court action. However, Nationwide has shown a clear legal right to the dismissal of Guster’s claims against it in the state-court action, and we conclude that the trial court erred in denying the motion to dismiss as to Nationwide. Accordingly, we grant the petition in part, deny it in part, and direct the Jefferson Circuit Court (1) to vacate its order insofar as it denies the motion to dismiss as to Nationwide, and (2) to enter an order dismissing Guster’s claims against Nationwide without prejudice, pursuant to the abatement statute and the compulsory-counterclaim rule.
PETITION GRANTED IN PART AND DENIED IN PART; WRIT ISSUED.
MOORE, C.J., and STUART, BOLIN, PARKER, MURDOCK, SHAW, WISE, and BRYAN, JJ., concur.