In a scathing ruling describing Health and Human Services Secretary Robert F. Kennedy Jr. as an “unserious” and “unsafe” leader, a federal judge in Oregon issued an order that will protect doctors and hospitals, and the transgender kids they treat, from the federal crackdown on gender-affirming care.

On Saturday, US District Judge Mustafa T. Kasubhai ruled that Kennedy was acting illegally when he attempted last December to unilaterially cut off federal funding for healthcare providers treating kids with gender dysphoria. “Unserious leaders are unsafe,” Kasubhai wrote in his ruling, adding that Kennedy’s actions “caused chaos and terror for all those people and institutions of our great nation.”

A coalition of 21 mostly Democratic-led states and Washington, DC, immedialy sued, arguing Kennedy had skipped the legally required procedures for such a drastic policy change. Last month, Kasubhai agreed that Kennedy had overstepped his authority and issued an order temporarily blocking the declaration. “The notion that ‘I will go forward and issue a declaration and see if we can get away with it’ is not a principle of governance that adheres to the overarching commitment to a democratic republic that requires the rule of law to be regarded and respected and honored as sacred,” the judge said at the time.

Now, Kasubhai has thrown a new wrench in the administration’s plans. His ruling on Saturday makes permanent his prior order blocking Kennedy’s declaration. But the judge also went further, prohibiting HHS from enacting any similar policy “which supercedes or purports to supercede the professionally recognized standards of care” in the states that sued. “Despite repeatedly emphasizing their commitment and obligation to protect children, Defendants have sweepingly wielded the Kennedy Declaration to threaten children’s hospitals that provide life-saving care to children,” Kasubhai wrote.