A federal judge has just overturned ObamaCare protections for transgender patients, which required doctors and hospitals to provide “medically necessary” services to transgender individuals, ruling that the 2016 policy violates the religious freedoms of Christian providers.

Judge Reed O’Connor in the Northern District of Texas ruled that the 2016 policy, which also prohibited providers and insurers who receive federal money from denying treatment or coverage to anyone based on sex, gender identity or termination of pregnancy, violates the Religious Freedom Restoration Act.

O’Connor stood by his December 2016 decision that the so-called “transgender mandate” implementing the Affordable Care Act’s anti-discrimination provision violates the Administrative Procedure Act (APA) because it defines prohibited sex discrimination in a way that is contrary to law, arbitrary, and capricious.

The judge also expanded on his previous ruling, holding that the rule violates RFRA. In the earlier decision, O’Connor said the rule’s challengers were likely to win because RFRA prohibits the government from imposing a substantial burden on religious exercise. The providers’ and insurers’ refusal to perform, refer for, or pay for gender transition-related care or abortions was a sincere religious exercise burdened by the rule, he said.

The rule’s defenders argued it satisfied RFRA’s requirements because it served a compelling interest in ensuring individuals aren’t discriminated against while seeking access to health care. But even if this was a compelling government goal, the defenders didn’t show the rule was the least restrictive means of accomplishing it, as RFRA requires, O’Connor said.

Christian health-care providers and five states sued the U.S. Health and Human Services Department in 2016 to stop the rule’s implementation. The HHS initially defended the rule, but the Trump administration switched sides and argued the rule should be invalidated. The HHS is working on an administrative fix.

Advocates have argued that removing protections for gender identity will allow health care providers, hospitals and insurers to discriminate against transgender patients.

Becket Fund for Religious Liberty, which argued against the government, celebrated the new decision as a “huge victory” for religious freedom.