NEW YORK (Reuters) - A federal judge threw out a challenge to a North Carolina law that allows government officials to refuse to perform same-sex marriages if they cite religious objections, claiming the couples who brought the suit failed to establish they were harmed by the law.

Dr. Jesus Hernandez and Oscar Hull are married outside of Mecklenburg County Register of Deeds office in Charlotte, North Carolina, October 2014. REUTERS/Davis Turner

The six plaintiffs, who include gay couples, argued in the suit filed in U.S. District Court in Asheville that the legislation - Senate Bill 2 - allows magistrates and other officials performing marriages to put their personal beliefs before their sworn constitutional duty.

The plaintiffs said on Wednesday they would appeal the ruling issued by U.S. District Judge Max Cogburn on Tuesday.

Cogburn said the plaintiffs had not argued they were being directly injured by the law, but instead said that their tax dollars were not being used according to the constitution.

He said they had not presented enough evidence to prove they had been harmed as taxpayers, although he did add that citizens could potentially suffer “real or emotional harm” as a result of the law because the magistrates decision to opt-out is secret.

North Carolina’s Republican-led legislature passed the law in 2015 as social conservatives nationwide pushed for so-called “religious freedom bills” in response to same-sex marriage becoming legal.

State legislators overrode Republican Governor Pat McCrory’s veto of the measure the same month the U.S. Supreme Court legalized gay marriage across the country.

Data from September 2015 showed at least 32 magistrates across the state have thus far exempted themselves as have Register of Deeds employees in five counties, according the Campaign for Southern Equality, which supported the suit.

“Senate Bill 2 expressly declares that magistrates religious beliefs are superior to their oath of judicial office,” said attorney Luke Largess from Tin Fulton Walker & Owen, which represented the couples in the case. “The law spends public money to advance those religious beliefs. That is a straightforward violation of the First Amendment.”

The office of North Carolina’s Attorney General declined to comment on the case, according to spokeswoman Noelle Talley.

Magistrates who ask to opt out are barred from performing any marriage, gay or heterosexual, for six months.

The nonprofit group the Liberty Counsel, which represented a magistrate as an intervenor in the case, said both the U.S. Constitution and the North Carolina Constitution require accommodation of religious beliefs even for government officials.

North Carolina has come under fire for another law passed earlier this year that prohibits people from using public restrooms not corresponding to their biological sex.

Major sports organizations including the National Collegiate Athletic Association and the National Basketball Association have moved their competitions from the state to protest the so-called bathroom bill.

(Corrects day of judge’s order to Tuesday from Monday)