Arrangements-Photography via Getty Images The owner of the funeral home said that “we have a dress code that is very specific that men will dress as men," according to a deposition.

Religious freedom is a valid defense for a Michigan business owner who fired a trans woman after she asked to dress in accordance with her gender identity, a federal judge ruled Thursday.

The Equal Employment Opportunity Commission, which enforces federal anti-discrimination laws, had sued the business, R.G. & G.R. Harris Funeral Homes, after it fired its funeral director, Amiee Stephens, a transgender woman who was undergoing transition.

Stephens, who had worked at the funeral home for six years and was known as Anthony Stephens until 2013, was fired after she sent a letter to her boss and coworkers announcing that she had gender dysphoria and was undergoing treatment, with plans for sex reassignment surgery at a later date.

“The first step I must take is to live and work full-time as a woman for one year,” she told coworkers. “At the end of my vacation on August 26, 2013, I will return to work as my true self, Amiee Australia Stephens, in appropriate business attire.”

But Stephens never went on vacation or made it back to work. Her boss, Thomas Rost, fired her soon after receiving her letter. “Anthony, this is not going to work out,” Rost told her at the time, according to a later deposition. He also said he fired her because Stephens “wanted to dress as a woman” and because “we have a dress code that is very specific that men will dress as men.”

Stephens filed a complaint with the EEOC, and the agency later sued in federal court, alleging the funeral home discriminated against her on the basis of sex and her gender identity in violation of Title VII of the Civil Rights Act of 1964. The law protects against discrimination in the workplace.

On Thursday, U.S. District Judge Sean Cox said that the funeral home deserved an exemption from complying with the law because compliance “would impose a substantial burden on its ability to conduct business in accordance with its sincerely-held religious beliefs.”

That language is lifted from the Religious Freedom Restoration Act, a federal law that protects individuals from government action that may “substantially burden” their religious tenets. Rost had raised it as a defense in the litigation.

Rost, it turns out, is a longtime Christian, and in an affidavit he said that he operates his business “as a ministry to serve grieving families.” The funeral home, he said, “administers its dress code based on our employees’ biological sex, not based on their subjective gender identity.”

According to Rost’s affidavit, “the Bible teaches that it is wrong for a biological male to deny his sex by dressing as a woman,” and that allowing Stephens to do so “would be violating God’s commands.” Curiously, Rost also said he wouldn’t have a problem with Stephens dressing as a woman if she did so during non-work hours.

In light of these and other beliefs, Cox ruled for the funeral home and found that requiring it to not discriminate against Stephens for living as a woman would impinge on those beliefs.

The court relied in great part in the Supreme Court’s decision in Burwell v. Hobby Lobby, which made waves in 2014 for allowing a religiously owned arts-and-crafts corporation to be exempted from providing contraceptive coverage to its female employees under the Affordable Care Act.

Brian Hauss, an attorney for the American Civil Liberties Union ― which filed a legal brief in support of Stephens ― said in an email that the ruling was “way, way out there” and could have serious repercussions down the road.

“I’m not aware of any court holding that an employer has a religious right to ignore Title VII’s prohibition against sex discrimination,” he said. “If allowed to stand, this decision would seriously jeopardize federal anti-discrimination protections for transgender people, women and people of color.”

A spokeswoman for the EEOC said the agency is disappointed in the ruling and that it’s evaluating whether to appeal.

According to the Transgender Law Center, only 20 states plus the District of Columbia have employment non-discrimination laws protecting transgender individuals. And even Title VII, which covers the entire country, doesn’t explicitly cover gender identity discrimination, but relies on court rulings to provide such coverage.

“Because there is no federal law explicitly banning discrimination against transgender people ... allowing employers to use religion to discriminate would put transgender people across the country ― people like Aimee Stephens ― at an even greater risk of losing their jobs just for being who they are,” Hauss said.