Businesses can cite religious freedom laws to discriminate against transgender employees, a federal court in Michigan ruled on Thursday — the first time a court found that the federal Religious Freedom Restoration Act (RFRA) can potentially be used to discriminate against LGBTQ people.

The decision is the latest in a back-and-forth between the federal government and Detroit-based R.G. & G.R. Harris Funeral Homes, which fired its transgender funeral director, Aimee Stephens, because she began transitioning and “dress[ing] as a woman” at work. The funeral home’s owner admitted that he fired her because she began transitioning, citing the business’s restrictive dress code.

But previously, the US Court of Appeals for the Sixth Circuit had found that the ban on sex discrimination encoded in federal law — specifically, Title VII of the Civil Rights Act — also protect trans people. So at first glance, that made the funeral home’s decision to fire a trans employee look illegal.

Related How most states allow discrimination against LGBTQ people

US District Judge Sean Cox acknowledged the higher court’s ruling over Title VII. But, citing the controversial Supreme Court ruling in Hobby Lobby, he said the federal RFRA may allow the funeral home to discriminate against its trans employee anyway. Cox agreed that the federal government has a compelling interest to protect LGBTQ people from discrimination, but he argued that the government had not proven that it took the least restrictive means necessary to achieve that goal in this case.

This speaks to legal technicalities in RFRAs: They broadly protect people’s religious rights as long as the government doesn’t prove it has a compelling interest to interfere with those rights and the government doesn’t prove it’s interfering with those rights in the least restrictive means possible.

In this case, Cox found that the Equal Employment Opportunity Commission (EEOC), a federal agency that oversees workplace discrimination claims, likely has a compelling interest to prevent discrimination against a trans employee. But the court concluded that the EEOC hadn’t proven that filing a lawsuit against the funeral home — instead of, say, finding some compromise between the funeral home and Stephens — was the least restrictive action it could take to prevent discrimination in this case.

The result: Stephens remains fired for now, although the EEOC is likely to appeal the case or try to show that a lawsuit really is the least restrictive means.

As Mark Joseph Stern wrote at Slate, chances are this decision will be overturned on appeal: “The bigger problem is its application of the ‘least restrictive means’ analysis to RFRA. Courts are not allowed to make up a less restrictive alternative in RFRA cases and scold the government for not complying with its fantasy solution. That’s doubly true in an employment discrimination case, where the universally accepted solution to unlawful termination is a Title VII suit.”

Legal experts have also repeatedly told me that religious freedom laws like RFRAs shouldn’t and don’t allow discrimination, because the government does have a compelling interest to prevent anti-LGBTQ discrimination.

But for now, this is the first example of a federal court using an RFRA to allow anti-LGBTQ discrimination — and LGBTQ advocacy groups, like HRC, are very concerned.

“This is a reckless ruling against a woman who was fired simply because she is transgender,” HRC Legal Director Sarah Warbelow said in a statement. “Judge Cox’s deeply disappointing decision has the possibility of setting an incredibly dangerous precedent that purported religious beliefs can be used as an excuse to violate non-discrimination laws. It has the potential of opening a Pandora's box of discrimination against a wide range of vulnerable communities. We are incredibly concerned about the implications.”