The Department of Children & Family Services seeks a writ of certiorari to quash the trial court’s order that involuntarily committed criminal defendant Michael Barnett to the Department’s care and custody after he was found incompetent to proceed on criminal charges. Both the Attorney General’s Office and Barnett agree that the trial court departed from the essential requirements of the law in committing Barnett to the Department because his involuntary pretrial commitment is not authorized under the provisions of section 916.13, Florida Statutes (2012). Therefore, we grant the petition, quash the trial court’s order to the extent that it committed Barnett to the Department, and remand for further proceedings.
Barnett is a criminal defendant in at least two cases pending in the circuit court. After questions arose concerning Barnett’s competence, he was examined by two separate mental health experts. Both determined that he was incompetent to proceed due to cognitive disorders arising from head trauma. In December 2011, the trial court adjudged Barnett incompetent to proceed and committed him to the Department for treatment and placement recommendations.
The Department provided treatment until June 2012, at which time the Department’s “forensic intervention trainer” reported that Barnett had reached his maximum level of competency and should be reevaluated. In August 2012, Dr. Jill Poorman reevaluated Barnett, opined that he remained incompetent to proceed, and stated that his competence was “likely unrestorable.” Following a subsequent evaluation in October 2012, Dr. Poorman indicated that Barnett’s competence was “unrestorable, given the nature of his diagnosis.” Dr. Poorman also opined that Barnett lacked the ability to adequately care for himself, and she noted that his behavior had become increasingly aggressive. Therefore, she recommended that he be placed in a locked facility, and she further expressed her belief that Barnett met the criteria for involuntary hospitalization. Based on Dr. Poorman’s report, the circuit court again adjudged Barnett incompetent to proceed in November 2012, and it again committed him to the Department “to be placed in a mental health treatment facility, pursuant to § 916.13(2), Fla. Stat.”
The Department filed a motion to intervene and to vacate the order committing Barnett to the Department, arguing that Barnett did not meet the statutory criteria for commitment to the Department because his competence could not be restored. On December 20, 2012, the circuit court granted the Department’s motion and vacated the portion of the November 2012 order that committed Barnett to the Department. In that order, the court noted that “Dr. Poorman was commencing civil commitment proceedings.” However, Barnett was thereafter held only briefly as a result of the Baker Act1 proceedings initiated by Dr. Poorman.
In March 2013, Barnett was back before the court on new criminal charges. On May 17, 2013, the circuit court entered an order adjudging Barnett incompetent and *432specifically finding that “he is not restora-ble to competency due to [his] mental illness.” Based on Barnett’s incompetence, the circuit court again committed him to the Department “to be placed in a mental health facility.”
The Department again filed a motion to intervene and vacate the order committing Barnett to the Department. The Department again pointed out that Barnett did not meet the statutory criteria for commitment to the Department because, as was previously found by both the expert and the trial court, his competence was not restorable. At an initial hearing on the Department’s motion, the circuit court expressed its frustration with the Department, saying:
We’re in the real world now, so do you want to have a real discussion or anything else you want to indicate regarding that? The guy can’t live in the community; he’s demonstrated over a period of time. He needs to be in the State Hospital; that’s the bottom line. So like it, don’t like it; that’s fine. You want to take it to the 2 DCA, have at it if that’s the case. I’m not putting the guy out on the street that has no ability to comply with a 916 release.
When the Department pointed out that it was simply following the dictates of the statute, the court told the Department that “quoting me what some obscure regulation says is not a solution and not an answer.” The court then suggested that the Department’s counsel see whether any compromise solution could be developed, and it reset the hearing for a week later.
At the rescheduled hearing, the Department again pointed to the statutory language that mandated that Barnett be re-storable to competency for commitment to the Department to be proper. The State conceded that Barnett did not meet the statutory criteria for commitment, but it noted that it had suggested that the Department should “compromise” and take Barnett anyway. The Department rejected the State’s suggested “compromise.” In denying the Department’s motion to vacate, the circuit court stated:
I’m not — you want that order? Go see the DCA. Let those three guys put Mr. Barnett back out on the street if they feel comfortable with that; guys or gals. So let the DCA make that call if that’s the call they want to make. Putting me in the position is unconscionable. It starts with the rules and regulations that suggest that.
If the DCA says release him, good, I’ll recuse myself and somebody else can release him, but I’m not going to do that. I would be abdicating my responsibility, and I’m not doing it. So no, no, hell no, under the circumstances. So the DCF motion to intervene and vacate is denied.
The Department now seeks a writ of cer-tiorari to quash the portion of the order committing Barnett to its care and custody-
Section 916.13 permits a court to involuntarily commit a defendant to the Department when that defendant is charged with a felony and found incompetent to proceed because of mental illness. However, the court may commit a defendant only if that defendant “meets the criteria for involuntary commitment to the department under the provisions of this chapter.” § 916.13(2). Those criteria include that there be “a substantial probability that the mental illness causing the defendant’s incompetence will respond to treatment and the defendant will regain competency to proceed in the reasonably foreseeable future.” § 916.13(l)(c) (emphasis added). A court that commits a defendant in violation of these statutory re*433quirements improperly encroaches on the legislature’s authority to prescribe the limits of an agency’s obligations and on an agency’s obligation to expend its appropriated funds in accordance with the laws governing that agency. Cf. Fla., Dep’t of State, Div. of Elections v. Martin, 916 So.2d 763, 769-70 (Fla.2005) (noting that it is the legislature’s obligation to set forth the standards and guidelines by which an agency must act and the court’s obligation to determine whether those agencies are acting in accord with the legislature’s intent); Dep’t of Revenue ex rel. v. Nesbitt, 975 So.2d 549, 551-52 (Fla. 4th DCA 2008) (holding that the trial court had no authority to order the Department of Revenue to take action in violation of its statutory obligations or in derogation of. its statutory authority); Office of State Attorney for Eleventh Judicial Circuit v. Polites, 904 So.2d 527, 532 (Fla. 3d DCA 2005) (noting that when a court interferes with an agency’s spending of its appropriated funds, the court -violates the separate of powers doctrine by “encroaching on the powers of the agency”). Moreover, doing so violates the rules of procedure promulgated by the supreme court, which provide that a court may commit a defendant for treatment only if “the defendant meets the criteria for commitment as set forth by statute.” Fla. R. Crim. P. 3.212(c)(3)(A). Hence, as recognized even by the trial judge here, a trial court simply has no authority to commit a criminal defendant to the Department when that defendant does not meet the statutory criteria. In fact, doing so is an abdication of the trial court’s responsibility to apply the laws duly enacted by the legislature.
In this ease, no one disputes that Barnett has a physical brain injury that has resulted in mental illness which is of such a nature that Barnett “is not restora-ble to competency.” As the court’s own findings demonstrate, Barnett does not satisfy the requirements for involuntary pretrial commitment found in section 916.'13(l)(c). While we certainly sympathize' with the trial court’s frustrations and unwillingness to contribute to potential chaos, we note that the rule of law simply does not permit a trial court to fashion its own remedy in derogation of statutory limitations, and good intentions cannot expand the trial court’s power in this regard. It is up to the legislature — not the trial court or this court — to close any gaps that may exist in the statutory scheme and to address the inadequacies of the existing law when applied to facts such as these. Hence, the trial court departed from the essential requirements of the law by committing Barnett in violation of the statutory requirements, and we must grant the Department’s petition and quash the trial court’s order to the extent that it involuntarily committed .Barnett.
On remand, the trial court must hold an expedited hearing to determine whether there is any lawful basis to continue to hold Barnett involuntarily. This may include consideration of whether the State should again initiate civil commitment proceedings pursuant to the Baker Act or other pertinent statutes. If no such lawful basis for involuntary commitment exists, the trial court must release Barnett. If the court orders release, it should consider whether appropriate conditions may again be lawfully imposed under rule 3.212(d). See, e.g., Dep’t of Children & Family Servs. v. Amaya, 10 So.3d 152, 157 (Fla. 4th DCA 2009) (noting that “[t]he proper course when an incompetent defendant does not meet the criteria for commitment, and cannot be restored to competency, is for the State to initiate civil commitment proceedings under the Baker Act or for the court to release the defendant ‘on appropriate conditions’ as provided in Rule 3.212(d)” (citing Abreu-Gutierrez v. *434James, 1 So.3d 262, 267 (Fla. 4th DCA 2009); Dep’t of Children & Families v. Gilliland, 947 So.2d 1262, 1263 (Fla. 5th DCA 2007); Oren v. Judd, 940 So.2d 1271, 1274 (Fla. 2d DCA 2006); Mosher v. State, 876 So.2d 1230, 1232 (Fla. 1st DCA 2004))). And, given the circuit court’s comments at the hearings leading to the order at issue here, we direct that this case be assigned to a different circuit judge on remand.
Petition granted and case remanded with instructions.
WALLACE, J., Concurs.
SILBERMAN, J., Concurs in result only.