(Reuters) - A federal law banning sex bias in the workplace prohibits discrimination against transgender workers, a U.S. appeals court said on Wednesday, ruling in favor of a funeral director who was fired after telling her boss she planned to transition to female from male.

FILE PHOTO - An activist waves a rainbow flag during the "Queer and Trans Dance Party" in protest of U.S. President Donald Trump outside of Trump Tower in Manhattan, New York, U.S., February 26, 2017. REUTERS/Darren Ornitz

The 6th U.S. Circuit Court of Appeals said RG & GR Harris Funeral Homes Inc in Detroit unlawfully discriminated against Aimee Stephens, formerly known as Anthony Stephens, based on her sex.

The court also said the funeral home failed to establish that the federal workplace law, Title VII of the Civil Rights Act of 1964, substantially burdened the ability of funeral home owner Thomas Rost, a devout Christian, to exercise his religious rights in his treatment of Stephens.

Several federal appeals courts have said that discriminating against transgender workers is a form of unlawful sex bias. But the 6th Circuit was the first to consider a religious defense in such a case.

The court decided a lawsuit that the U.S. Equal Employment Opportunity Commission filed on behalf of Stephens in 2014.

The Alliance Defending Freedom, a conservative Christian legal group that represents the funeral home, said the decision allowed the government to “strong-arm” religious employers.

In a statement, Stephens’ lawyers at the American Civil Liberties Union called the decision an important victory for transgender workers.

Rost had claimed that he viewed his work as a religious service for grieving families, and that employing a transgender woman would distract customers.

Rost said he could not be held liable for discriminating against Stephens under the Religious Freedom Restoration Act, which bars the government from burdening an individual’s religious practice.

But Circuit Judge Karen Nelson Moore, writing for the court on Wednesday, said Rost could not use his customers’ “presumed biases” as an excuse for firing Stephens.

“Tolerating Stephens’s understanding of her sex and gender identity is not tantamount to supporting it,” Moore wrote.

The decision reversed a 2016 ruling by a federal judge in Detroit who had said that Rost was shielded from the lawsuit because he operated his business “as a ministry.”

Rost also said that because his company pays for employees’ work clothes, he would be forced to violate his religious beliefs by paying for Stephens to wear women’s clothing. But the court said he was not legally required to pay for the clothes, so it would not burden his religious practice.