J.E. Estes Wood Company, Inc. (“Estes”), a timber-management company, and A.A. Nettles, Sr. Properties, Ltd. *107(“Nettles”), petition this Court for a writ of mandamus directing the Monroe Circuit Court to vacate an order denying their motion to dismiss, pursuant to Ala.Code 1975, § 6-5-440, the action of Shawnee Terminal Railroad (“Shawnee”) against them. We grant the petition and issue the writ.
I. Factual and Procedural Background
The facts are undisputed. On March 4, 2009, Shawnee filed a complaint in the United States District Court for the Southern District of Alabama, naming as defendants Estes and Nettles. The complaint alleged that Shawnee was the owner of “a common carrier rail line running from Flo-maton, Alabama, to Beatrice, Alabama” (“the rail line”). The complaint also contained the following relevant factual aver-ments:
“13. The rail line runs generally north-to-south through a section of property owned by [Nettles] and located in Monroe County, Alabama. The portion of the rail line that runs through [Nettles’s] property includes a 275 ft. wooden bridge, which spans a ravine and tributary of water on the property. The bridge is commonly referred to as ‘Bridge 38.’
“15. On or about March 7, 2007, [Nettles and Estes] tried to perform a ‘controlled burn’ on [Nettles’s] property. However, [they] lost control of the fire. The fire ignited Bridge 38 and the surrounding tracks. The fire totally destroyed Bridge 38 and the surrounding tracks.”
The complaint sought compensatory and/or punitive damages on theories of (1) violation of 18 U.S.C. § 1992(a), (2) negligence, (3) wantonness, (4) negligence per se, (5) strict liability, and (6) trespass. The action commenced by this complaint is hereinafter referred to as “the federal action.”
Two days later, on March 6, 2009, Shawnee filed a complaint based on the same facts in the Monroe Circuit Court against the same defendants (hereinafter referred to as “the state action”). The later filed complaint in the state action sought the same relief under the same theories as did the earlier filed complaint in the federal action. According to Shawnee, it “filed [the state action] to preserve a forum to litigate its claims in the event the federal action was dismissed for lack of subject matter jurisdiction more than two years after the fire.” Shawnee’s brief, at 2 (emphasis added).
On March 27, 2009, Nettles and Estes moved the federal district court to dismiss the federal action for lack of subject-matter jurisdiction. In April 2009, while the motion to dismiss the federal action was pending, Estes and Nettles moved to dismiss the state action, pursuant to Ala.Code 1975, § 6-5-440, the abatement statute, which 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.”
(Emphasis added.)
In response to the motions to dismiss the state action, Shawnee moved the Monroe Circuit Court to stay the state action pending resolution of the motion to dismiss the earlier filed federal action. On July 27, 2009, the Monroe Circuit Court denied the motions to dismiss and granted the motion to stay the state action “until resolution of the [federal] action.” On September 4, 2009, Estes and Nettles petitioned this *108Court for a writ of mandamus, directing the dismissal of the state action. Two weeks later, on September 18, 2009, the federal district court dismissed the federal action. Shawnee has appealed from that judgment, and that appeal is pending in the United States Court of Appeals for the Eleventh Circuit.
II. Discussion
“[A] writ of mandamus is an extraordinary remedy, which requires the petitioner to demonstrate a clear, legal right to the relief sought, or an abuse of discretion.” Ex parte Palm Harbor Homes, Inc., 798 So.2d 656, 660 (Ala.2001). Mandamus is the appropriate remedy to correct a trial court’s failure to properly apply § 6-5-440. See Ex parte Chapman Nursing Home, Inc., 903 So.2d 813 (Ala.2004); Ex parte Breman Lake View Resort, L.P., 729 So.2d 849, 852 (Ala.1999).
“[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 dismissal of an earlier filed federal action does not render § 6-5-440 inapplicable during the pendency of an appeal from that dismissal. L.A. Draper & Son, Inc. v. Wheelabrator-Frye, Inc., 454 So.2d 506, 508 (Ala.1984) (“An action is deemed pending in federal court so long as a party’s right to appeal has not yet been exhausted or expired.”).
It is undisputed that § 6-5-440 applies to the state action, and Estes and Nettles contend that the statute requires the dismissal of the state action. In other words, the stay ordered by the trial court does not, according to Estes and Nettles, satisfy the statute. Shawnee insists that the statute is satisfied by a “stay of this case in lieu of dismissal ” as a matter of discretion. Shawnee’s brief, at 13 (emphasis added). We agree with Estes and Nettles.
“Section 6-5-440, as initially codified in Ala.Code 1907, § 2451, was ‘a transcript of section 4331 of the Civil Code of Georgia.’ Ex parte Dunlap, 209 Ala. 453, 455, 96 So. 441, 442 (1923). See current version at Ga.Code Ann. § 9-2-5(a) (Michie 1982). However, these statutes merely codified the principle expressed in the common-law maxim: ‘Nemo debet bis vexari (si constet curiae quod sit) pro una et eadem causa, ’ that is: ‘No man ought to be twice troubled or harassed (if it appear to the court that he is), for one and the same cause.’ O’Barr v. Turner, 16 Ala.App. 65, 67-68, 75 So. 271, 274 (1917), cert. denied, 200 Ala. 699, 76 So. 997 (1917). This rule was well established in Alabama long before it was first codified in Ala.Code 1907, § 2451. In Foster v. Napier, 73 Ala. 595 (1883), for example, this Court explained:
“ ‘The doctrine is thus stated in 1 Bac. Ab. 28, M.: “The law abhors multiplicity of actions; and, therefore, whenever it appears on record, that the plaintiff has sued out two writs against the same defendant, for the same thing, the second writ shall abate; for if it were allowed that a man should be *109twice arrested, or twice attached by his goods for the same thing, by the same reason he might suffer in infini-tum; ... if there was a writ in being at the time of suing out the second, it is plain the second was vexatious and ill ab initio.” ’
“Foster v. Napier, 73 Ala. 595, 603 (1883) (quoting 1 M. Bacon, A New Abridgment of the Law 28 (1843)). In fact, the rule was well established as early as 1461, for it was thoroughly discussed and applied in Y.B. 39 Henry VI, pi. 12 (1461), case quoted in toto, Commonwealth v. Churchill, 5 Mass. 174 (1809); see also Sparry’s Case, 5 Coke 61a., 77 Eng. Rep. 148 (K.B.1591)
Ex parte State Mut. Ins. Co., 715 So.2d 207, 213 (Ala.1997) (emphasis added).
Historically, a violation of the prohibition against multiple pending actions was redressable by a “plea in abatement.” Benson v. City of Scottsboro, 286 Ala. 315, 317, 239 So.2d 747, 748-49 (1970). The plea in abatement of simultaneous actions was the predecessor of the modern motion to dismiss. Terrell v. City of Bessemer, 406 So.2d 337, 340 (Ala.1981) (“In this jurisdiction the rule is that a motion to dismiss (formerly a plea in abatement) will be granted where defendant moves to dismiss plaintiff’s second action for the same cause, even though plaintiff dismissed his first action after the motion to dismiss was filed.”). Thus, a stay is not an abatement. See Ex parte DeArman, 694 So.2d 1288, 1290 (Ala.1997).
Moreover, where § 6-5-440 applies, it “compels dismissal. ” Ex parte Canal Ins. Co., 534 So.2d 582, 585 (Ala.1988) (emphasis added) (“Since the matter raised in the state court complaint constitutes a compulsory counterclaim in the federal court action that was pending at the time the state court action was commenced, the statute compels dismissal of the state court action.”). See Ex parte Bennett, 231 Ala. 223, 224, 164 So. 298, 299 (1935) (“A plea in abatement goes to the present right to maintain the action. To sustain the plea results in a dismissal of the action.”). This is true, even where the party invoking the statute requests a dismissal or, in the alternative, a stay. Canal Ins., supra.
Shawnee cites two cases in support of its contention that the statute does not mandate a dismissal, namely, Ex parte Am-South Bank, 735 So.2d 1151 (1999), and Ex parte University of South Alabama Foundation, 788 So.2d 161 (Ala.2000). Am-South Bank does not aid Shawnee, and University of South Alabama was wrongly decided.
AmSouth Bank involved “an action containing class allegations that was commenced in a state court [against AmSouth Bank] after an action containing similar class allegations ... had been commenced [against AmSouth], but not yet certified [as a class action], in the United States District Court for the Southern District of Alabama.” 735 So.2d at 1154 (Cook, J., dissenting). AmSouth moved the state court to dismiss the action, citing § 6-5-440, as well as Ex parte First National Bank of Jasper, 717 So.2d 342 (Ala.1997), and First Tennessee Bank, N.A. v. Snell, 718 So.2d 20 (Ala.1998). AmSouth Bank, 735 So.2d at 1152. The state court denied the motion, and AmSouth petitioned this Court for a writ of mandamus directing the trial judge to grant its motion to dismiss the action.
This Court declined to order a dismissal and, instead, issued a writ of mandamus ordering a stay of the action in the state court pending a resolution of the certification issue in the federal court. However, it did so, not on the authority of § 6-5-U.O but on the authority of the rule announced in Jasper as refined by Snell. That rule, which this Court propounded specifically *110to deal with the peculiar issues raised by the filing in the courts of this State of multiple actions containing overlapping class allegations, is stated as follows:
“The first class action prevails over a second substantially similar case filed in another court.... [T]he court in which the second class action is filed should refuse to exercise jurisdiction over the case once it is apprised of the fact that another court has assumed jurisdiction of substantially the same case (involving the same parties, the same issues, etc).”
Snell, 718 So.2d at 23 (emphasis added) (quoted in AmSouth Bank, 735 So.2d at 1154). The Court in AmSouth Bank stated:
“As of the date of the release of this opinion, there has been no certification of a class in the [first-filed federal] action. Therefore, the only injury Am-South has incurred in regard to the State action ... is a requirement that AmSouth produce documents, prepare for depositions, and prepare for a class-certification hearing, while already doing these same things in regard to the action in .the federal district court. This injury should be addressed not by abating [the later filed] State action, but by putting it on administrative hold until the United States District Court certifies, or refuses to certify, the class in the [federal] action, as to the breach-of-contract and fraud claims.”
735 So.2d at 1154 (emphasis added).
Significantly, however, the AmSouth Bank Court further stated: “If a class is certified in the [federal] action and that class includes [the named plaintiff in the State action] and his claims, then [the] State action must be abated.” 735 So.2d at 1154 (emphasis added). In other words, the Court recognized that, if a class encompassing the action in the state court was eventually certified in the federal court, then the application of § 6-5-440 would require the dismissal of the action brought in the state court. Thus, Am-South Bank actually aids Estes and Nettles.
A year after AmSouth Bank was decided, this Court, in University of South Alabama, did order a stay in a case, purportedly applying § 6-5-440. That case involved a petition by parties who were potential counterclaim defendants in an action in federal court, seeking a writ of mandamus directing the trial judge in a later filed action against them in a state court either (1) to dismiss or (2) to stay the action in the state court. 788 So.2d at 163. Without citing any legal authority supporting a stay, this Court chose the “second option” as being “more appropriate under the circumstances.” 788 So.2d at 165.
University of South Alabama is inconsistent with the plain language of § 6-5-440 and the body of caselaw interpreting it, including Canal Insurance. According to the statute, “the pendency of the former [action] is a good defense to the latter.” (Emphasis added.) Otherwise stated, the rule stated in § 6-5-440 is an affirmative defense. Veteto v. Yocum, 793 So.2d 814, 815-16 (Ala.Civ.App.2001). “This Court has defined an affirmative defense as ‘ “[a] defendant’s assertion of facts and arguments that, if true, will defeat the plaintiffs ... claim, even if all the allegations in the complaint are true.’”” Ex parte Gadsden Country Club, 14 So.3d 830, 833-34 (Ala.2009) (quoting Lloyd Noland Found., Inc. v. HealthSouth, Inc., 979 So.2d 784, 791 (Ala.2007), quoting in turn Black’s Law Dictionary 451 (8th ed.2004)). Thus, the pendency of a former action abates, or defeats, a subsequently filed action against the same party for the same cause. See Ex parte Canal Ins., supra; Ex parte Bennett, supra. A stay is, there*111fore, not an option that can be exercised at the discretion of the judiciary.
This is so, because the principle codified by the statute “is founded upon the policy of discouraging a multiplicity of suits — of protecting the defendant from oppression, [and] from the grievance of double vexation for the same cause or thing.” Foster v. Napier, 73 Ala. 595, 606 (1883). “[W]hen a defendant is twice im-pleaded by the same plaintiff, for the same thing, the oppression and vexation is not matter of fact; it is a conclusion of law, and is not dependent upon an inquiry into the actual circumstances of the two cases.” 73 Ala. at 603.
“[T]he institution of the second action” is, in itself, an “offense or wrong, so to speak.” Interstate Chem. Corp. v. Home Guano Co., 199 Ala. 583, 584, 75 So. 166, 166 (1917) (emphasis added). The “offense or wrong” that the statute seeks to prevent consists in the very “existence simul et semel” of the second action. Foster, 73 Ala. at 603. The wrong committed “ ‘was vexatious and, ill ab initio.’ ” Id. (emphasis added). The plaintiff might “accomplish [an] atonement” for the offense “by discontinuing his first action” before the plea in abatement is filed, but not afterward.1 Interstate Chem., 199 Ala. at 585, 75 So. at 166. However, a mere stay of the second action accomplishes no such “atonement.”
“The plaintiff is,” after all, “the ‘master of his complaint.’ ” Noland Health Servs. Inc. v. Wright, 971 So.2d 681, 693 (Ala.2007). “There can be no necessity for the institution or the pen-dency of two suits for the same matter at the same time. The security of the plaintiff can not require it.” Foster, 73 Ala. at 606 (emphasis added). If the first action is “defective, it is the fault of the plaintiff, not of the defendant.” Id. at 605. Indeed, recognizing a stay of the second action as an acceptable option, pending the outcome of the first, would not only encourage forum shopping, but also “ ‘would encourage and cultivate a want of due care in making the first one effectual.’ ” Id. at 606 (quoting Gamsby v. Ray, 52 N.H. 513 (1872)). Even if the later filed action is stayed, the defendant remains obligated to stand before both courts prepared to defend against the same cause.
Shawnee essentially concedes that it had reservations about the viability of its federal action and that it sought to hedge its bet by filing the state action. Shawnee’s brief, at 2. This is precisely the evil the statute aims to prevent.
We hold, therefore, that § 6-5-440 is not satisfied by a stay of the later filed case in lieu of dismissal. Because the statute provides no such discretionary authority, we regard University of South Alabama as an aberration in the caselaw construing and applying § 6-5-440. Thus, to the extent that it purports to authorize a stay in lieu of a dismissal, it is hereby overruled.
III. Conclusion
For the foregoing reasons, we conclude that Estes and Nettles have demonstrated a clear, legal right to a writ of mandamus *112directing the Monroe Circuit Court (1) to vacate its July 27, 2009, order, and (2) to enter an order dismissing this action without prejudice, pursuant to § 6-5-440. We therefore grant the petition and issue the writ.
PETITION GRANTED; WRIT ISSUED.
COBB, C.J., and STUART, SMITH, BOLIN, PARKER, MURDOCK, and SHAW, JJ., concur.
LYONS, J., concurs specially.