
850 So.2d 578 (2003)
Terry MALLOY, Wayne Ingram, and Steve Ingram, Petitioners,
v.
GUNSTER, YOAKLEY, VALDES-FAULI & STEWART, P.A.; and Charles J. Duffy, III, Respondents.
No. 2D02-4413.
District Court of Appeal of Florida, Second District.
June 13, 2003.
Rehearing Denied July 22, 2003.
*579 Michael C. Sasso of Dempsey & Sasso, Orlando, and Sheldon E. Richie of Richie & Gueringer, P.C., Austin, TX, for Petitioners.
John W. Frost, II, and Peter W. van den Boom of Frost Tamayo Sessums & Aranda, P.A., Bartow, for Respondent, Gunster, Yoakley, Valdes-Fauli & Stewart, P.A.
Morey Raiskin and Karen A. Williams of Lowndes, Drosdick, Doster, Kantor & Reed, P.A., Orlando, for Respondent, Charles J. Duffy, III.
VILLANTI, Judge.
Terry Malloy, Wayne Ingram, and Steve Ingram (collectively Petitioners) seek either a writ of mandamus or a writ of certiorari to avoid the effect of the trial court's order abating their action against Gunster, Yoakley, Valdes-Fauli, & Stewart, P.A. (Gunster Yoakley), Charles J. Duffy, III, United Container, LLC, Andrew Todd Bullock, and Bradley W. Campbell until resolution of United Container's bankruptcy action.[1] Because a trial court has no clear legal duty to rule in a particular way on a particular motion, there is no basis for issuing a writ of mandamus. However, because the trial court departed from the essential requirements of the law in abating the action, we treat this petition as a petition for writ of certiorari, grant the petition, and quash the trial court's order.
In July 2000, Petitioners sued United Container, Bullock, Campbell, Gunster Yoakley, and Duffy in Florida state court after a series of complex financial transactions between Petitioners and United Container went awry. While the complaint alleged numerous causes of action, Petitioners essentially contended that all of the defendants conspired to defraud them out of $3.1 million that Petitioners either loaned to or invested in United Container. As to Gunster Yoakley and Duffy, Petitioners also asserted causes of action for breach of fiduciary duty and legal malpractice based on Gunster Yoakley and Duffy allegedly representing both Petitioners and United Container during the negotiations that led to the transactions.
In December 2001, United Container filed a voluntary bankruptcy petition in the bankruptcy court for the Middle District of Florida. This filing triggered an automatic stay of the state court case against United Container. See 11 U.S.C. § 362(a)(1) (providing that the filing of a petition for bankruptcy operates as a stay of the commencement or continuation of any judicial, administrative, or other action against the debtor in any forum). Thus, Petitioners' state court action against United Container was automatically stayed.
In an effort to proceed with their claims against Gunster Yoakley and Duffy, Petitioners filed a motion in the state court action seeking to sever their claims against United Container and to go to trial against the remaining defendants. The trial court denied this motion, finding that United *580 Container was an indispensable party in the state court action.
In response to this ruling, Petitioners filed a motion in the bankruptcy action in January 2002 seeking to modify the automatic stay to allow the state court case to proceed so that Petitioners could liquidate their claims against United Container. Petitioners assured the bankruptcy court that they would not attempt to collect on any judgment obtained against United Container. Subject to this assurance, the bankruptcy court modified the automatic stay to allow Petitioners to proceed in the state court action against United Container. Because none of the other defendants in the state court action were subject to the automatic stay, the result of this ruling was to allow the entire state court action to proceed.
Based on that ruling, the parties to the state court action returned to state court and proceeded with discovery. However, in August 2002, Gunster Yoakley and Duffy filed new motions asking the state court to abate the pending action. In these motions, Gunster Yoakley and Duffy contended for the first time that the bankruptcy estate was solvent and that the state court litigation should be abated until the conclusion of the bankruptcy action to avoid a double recovery by Petitioners. Gunster Yoakley and Duffy also contended that if Petitioners recovered their money in the bankruptcy action, their pending state court claims would fail as a matter of law because Petitioners would have suffered no damages. United Container did not join in these motions.
At the hearing on these motions, Petitioners argued that the solvency of the bankruptcy estate was irrelevant to their state court claims. Petitioners pointed out that they could not obtain a double recovery against United Container because they were not permitted to execute on any judgment obtained in the state court proceeding. Further, they could not obtain a double recovery against Gunster Yoakley and Duffy because any monies received in the bankruptcy action that duplicated damages awarded in the state court action would be an offset against the damages award. Petitioners also argued that any stay or abatement of the trial court proceedings would violate their due process rights by denying them any forum in which to try their claims against Gunster Yoakley and Duffy. Petitioners also pointed out that their state court action had been pending before the bankruptcy action was commenced and that the bankruptcy court had modified the automatic stay specifically to allow Petitioners' state court claims to be liquidated. Finally, Petitioners noted that United Containerthe only party entitled to the benefits of the bankruptcy actionwas not seeking to have the state court action stayed and that United Container agreed that the state court litigation should proceed.
Despite these arguments, the trial court granted Gunster Yoakley's and Duffy's motions to abate the state court action, finding that "[i]t now appears that the assets exceed the liabilities [in the bankruptcy estate] and plaintiffs may be fully compensated from the estate. Until that matter is determined, it makes little sense to continue this action." Petitioners then filed their petition for writ of certiorari with this court. In the petition, Petitioners contend that they are entitled to a writ of certiorari because the trial court departed from the essential requirements of the law in granting the motion to stay and/or abate. We agree.
The common law writ of certiorari is a special mechanism whereby an upper court can direct a lower tribunal to send up the record of a pending case so that the upper court can "be informed of" *581 events below and evaluate the proceedings for regularity. The writ functions as a safety net and gives the upper court the prerogative to reach down and halt a miscarriage of justice where no other remedy exists.

Broward County v. G.B.V. Int'l, Ltd., 787 So.2d 838, 842 (Fla.2001) (footnote omitted). In order for the writ to issue, the petitioner must establish that the trial court departed from the essential requirements of the law. Kash N' Karry Food Stores, Inc. v. Smart, 814 So.2d 530, 532 (Fla. 2d DCA 2002); Parkway Bank v. Fort Myers Armature Works, Inc., 658 So.2d 646, 648 (Fla. 2d DCA 1995).
[T]he departure from the essential requirements of the law necessary for the issuance of a writ of certiorari is something more than a simple legal error. A district court should exercise its discretion to grant certiorari review only when there has been a violation of a clearly established principle of law resulting in a miscarriage of justice.

Allstate Ins. Co. v. Kaklamanos, 843 So.2d 885, 889 (Fla.2003) (citing Ivey v. Allstate Ins. Co., 774 So.2d 679, 682 (Fla.2000), and Haines City Cmty. Dev. v. Heggs, 658 So.2d 523, 528 (Fla.1995)).
In this case, the trial court violated a clearly established principle of law. When a state and federal court have concurrent jurisdiction over the same parties and the same subject matter, the court in which jurisdiction first attached should determine the controversy and decide every issue properly raised in the case before it. Wade v. Clower, 94 Fla. 817, 114 So. 548, 551 (1927); State v. Harbour Island., Inc., 601 So.2d 1334, 1335 (Fla. 2d DCA 1992); Schwartz v. DeLoach, 453 So.2d 454, 454-55 (Fla. 2d DCA 1984); Shooster v. BT Orlando Ltd. P'ship, 766 So.2d 1114, 1115-16 (Fla. 5th DCA 2000). Once that court has decided all the issues before it, the parties may pursue whatever issues remain in the other court. Judicial economy is served by deciding the first case first without regard to the whims of the parties or their desired forum. In this case, jurisdiction first attached in the state court. Therefore, under clearly established law, the state court should decide all the issues before itnot defer to the bankruptcy action. The trial court's refusal to decide the issues before it in this case violated a clearly established principle of law.
Moreover, under the unique facts of this case, the trial court's ruling results in a miscarriage of justice. Were it not for United Container's bankruptcy, the state court case against all defendants would have already been tried.[2] While United Container is entitled to the protections from ongoing litigation afforded a debtor in bankruptcy, United Container is not seeking those protections. Rather, Gunster Yoakley and Duffy are using the protections of United Container's bankruptcy action as a shield to avoid a preexisting state court action and as a sword to impose their desired forum on Petitioners. Allowing Gunster Yoakley and Duffy to manipulate the state and federal courts' concurrent jurisdiction to deny Petitioners a timely trial on the merits of their state court action constitutes a miscarriage of justice.
Because the trial court's ruling constitutes a departure from the essential requirements of the law, we grant the petition, quash the trial court's order staying the state court proceedings, and remand *582 for further proceedings in the state court action.
Petition granted.
CASANUEVA, J., and THREADGILL, EDWARD F., Senior Judge, Concur.
NOTES
[1]  While the trial court's order affects all of the defendants in Petitioners' state court action, Gunster Yoakley and Duffy were the only defendants who sought to abate the state court action and are the only defendants who responded to this petition.
[2]  The limited record before us indicates that the state court case was scheduled to be tried in September 2002.
