A Catholic school in North Carolina was legally allowed to fire a gay teacher who announced his marriage to another man on social media a decade ago, according to a federal appeals court ruling, reversing a judge's earlier decision.

A panel of the 4th U.S. Circuit Court of Appeals in Richmond, Virginia, on Wednesday reversed a 2021 ruling stating that Charlotte Catholic High School and the Roman Catholic Diocese of Charlotte had violated teacher Lonnie Billard's federal employment protections against sex discrimination under Title VII of the Civil Rights Act.

The school said Billard was not brought back as a substitute teacher because of his "advocacy in favor of a position that is opposed to what the church teaches about marriage," according to a court document.

U.S. District Judge Max Cogburn ruled that Billard, who worked full-time as a teacher for a decade until 2012, was a lay employee for the limited purpose of teaching secular classes. The judge said a trial would still need to be held to determine appropriate relief for him.

CATHOLIC COLLEGE DEFENDS PRO-ABORTION NUN AS COMMENCEMENT SPEAKER AMID BACKLASH

Gavel

A Catholic school in North Carolina was legally allowed to fire a gay teacher who announced his marriage to another man on social media a decade ago, according to a federal appeals court ruling. (MediaNews Group/Boston Herald via Getty Images)

A 2020 ruling by the Supreme Court also found that Title VII protected workers who were terminated for being gay or transgender.

Circuit Judge Pamela Harris, however, wrote in Wednesday's ruling that Billard fell under a "ministerial exception" to Title VII that courts have taken from the First Amendment that protects religious institutions in how they treat employees "who perform tasks so central to their religious missions — even if the tasks themselves do not advertise their religious nature."

Billard, who primarily taught English as a substitute after returning from retirement as a drama teacher at Charlotte Catholic High School, fell under this exception because Charlotte Catholic expected teachers to integrate faith throughout the curriculum, Harris wrote, adding that the school's apparent expectation that Billard be prepared to teach religion as needed speaks to his role in the school’s religious mission.

"The record makes clear that (Charlotte Catholic) considered it 'vital' to its religious mission that its teachers bring a Catholic perspective to bear on Shakespeare as well as on the Bible," Harris wrote. "Our court has recognized before that seemingly secular tasks like the teaching of English and drama may be so imbued with religious significance that they implicate the ministerial exception."

VATICAN PREPARING 'GUIDELINES' FOR 'APPARITIONS,' 'OTHER SUPERNATURAL PHENOMENA'

Gay pride flag

Circuit Judge Pamela Harris wrote in Wednesday's ruling that Lonnie Billard fell under a "ministerial exception" to Title VII. (REUTERS/Axel Schmidt)

Billard began working at Charlotte Catholic in 2001, the year after he met his now-husband. He announced their decision to get married shortly after same-sex marriage was made legal in North Carolina in 2014, and he filed a lawsuit challenging his termination in 2017.

The American Civil Liberties Union and a Charlotte law firm that helped Billard file his lawsuit said Wednesday’s ruling was "a heartbreaking decision for our client who wanted nothing more than the freedom to perform his duties as an educator without hiding who he is or who he loves."

The joint statement said the ruling threatens to infringe on the rights of LGBTQ+ workers by "widening the loopholes employers may use to fire people like Mr. Billard for openly discriminatory reasons."

An attorney for a group that defended the Charlotte diocese praised the ruling, calling it a "victory for people of all faiths who cherish the freedom to pass on their faith to the next generation."

Rainbow flag waving on the street during a gay pride celebration with unrecognizable people lining the sidewalk in the background. U.S. embassies can now display the flag on the same pole as the American flag in June, during Pride month.

Lonnie Billard announced his decision to get married shortly after same-sex marriage was made legal in North Carolina in 2014. (iStock)

CLICK HERE TO GET THE FOX NEWS APP

"The Supreme Court has been crystal clear on this issue: Catholic schools have the freedom to choose teachers who fully support Catholic teaching," Luke Goodrich of The Becket Fund for Religious Liberty said.

Attorneys general from nearly 20 Democrat-leaning states and lawyers from Christian denominations and schools and other organizations filed briefs in the case.

Circuit Judge Paul Niemeyer joined Harris’ opinion, while Circuit Judge Robert King wrote a separate opinion saying he agreed with the reversal but also questioned the use of the ministerial exemption. King wrote instead that Charlotte Catholic fell under a separate exemption in Title VII for religious education institutions dismissing an employee.

The Associated Press contributed to this report.