CHARLOTTE, North Carolina — A gay substitute teacher was wrongfully fired by a Catholic school in North Carolina after he announced in 2014 on social media that he was going to marry his longtime partner, a federal judge has ruled.

U.S. District Judge Max Cogburn ruled Friday that Charlotte Catholic High School and the Diocese of Charlotte violated Lonnie Billard’s federal protections against against sex discrimination under Title VII of the Civil Rights Act. Cogburn granted summary judgment to Billard and said a trial must still be held to determine appropriate relief for him.

“After all this time, I have a sense of relief and a sense of vindication. I wish I could have remained teaching all this time,” Billard said in a statement released Friday by the ACLU, which represented him in court. “Today’s decision validates that I did nothing wrong by being a gay man.”

Billard taught English and drama full time at the school for more than a decade, earning its Teacher of the Year award in 2012. He then transitioned to a role as a regular substitute teacher, typically working more than a dozen weeks per year, according to his 2017 lawsuit.

He posted about his upcoming wedding in October 2014 and was informed by an assistant principal several weeks later that he no longer had a job with the school, according to the ruling.

The defendants said that they fired Billard not because he was gay, but rather because “he engaged in ‘advocacy’ that went against the Catholic Church’s beliefs” when he publicly announced he was marrying another man, the ruling said.

But Cogburn ruled that the school’s action didn’t fit into exemptions to labor law that give religious institutions leeway to require certain employees to adhere to religious teachings, nor was the school’s action protected by constitutional rights to religious freedom.

“Plaintiff is a lay employee, who comes onto the campus of a religious school for the limited purpose of teaching secular classes, with no mandate to inculcate students with Catholic teachings,” Cogburn wrote.

The diocese released a statement to The Charlotte Observer saying that it disagreed with the ruling and was considering how to proceed.

“The First Amendment, federal law, and recent Supreme Court decisions all recognize the rights of religious organizations to make employment decisions based on religious observance and preference,” the statement said. “They do not — and should not — compel religious schools to employ teachers who publicly contradict their teachings.”