(Reuters) - A federal judge ruled on Thursday that a Detroit funeral home that “operates as a ministry” was exempt from a law protecting transgender employees because of its owner’s Christian beliefs.

U.S. District Judge Sean Cox dismissed a 2014 lawsuit by the Equal Employment Opportunity Commission that said RG & GR Harris Funeral Homes Inc unlawfully fired funeral director Aimee Stephens when she told her bosses she would transition from male to female. It was one of the agency’s first lawsuits on behalf of a transgender worker.

Following milestone achievements in gay rights including same-sex marriage becoming legal nationwide in 2015, transgender rights have become an increasingly contentious issue in the United States.

The EEOC said Harris violated Title VII of the Civil Rights Act of 1964, which prohibits employment discrimination on the basis of gender stereotyping. Harris said it had a religious right to fire Stephens and that she was also biologically male and violated a dress code requiring men to wear suits.

Cox agreed on Thursday with Harris on both points. The company’s owner, Thomas Rost, is a devout Christian whose life’s work stems from his religious beliefs, including that shunning one’s biological sex is an affront to God, the judge wrote.

“Rost operates the funeral home as a ministry to serve grieving families while they endure some of the most difficult and trying times in their lives,” Cox wrote.

An EEOC spokeswoman said: “We are disappointed with the decision and reviewing next steps.”

Douglas Wardlow of the Alliance Defending Freedom, a Christian legal group representing the funeral home, applauded the ruling, saying in a statement: “The feds shouldn’t strong-arm private business owners into violating their religious beliefs, and the court has affirmed that here,”

Cox based his ruling largely on a 2014 U.S. Supreme Court decision that granted craft-store chain Hobby Lobby a religious exemption from providing employees with insurance coverage for contraception. But Justice Samuel Alito, writing for the court in that case, said the ruling did not necessarily apply to cases involving discrimination.

Several U.S. appeals courts have held that federal law prohibiting gender bias applies to transgender people, but none have addressed the issue of religious freedom in those cases.

Jillian Weiss, executive director of the Transgender Legal Defense and Education Fund, which was not involved in the funeral home case, said that under Cox’s decision: “People could be forced to conform to outmoded masculine and feminine stereotypes in order to keep their jobs.”

The case is Equal Employment Opportunity Commission v. RG & GR Harris Funeral Homes Inc, U.S. District Court for the Eastern District of Michigan, No. 14-cv-13710.