RALEIGH, N.C. - A federal judge has dismissed a challenge to a North Carolina law that allows magistrates to refuse to marry same-sex couples by citing religious beliefs.

The judge in Asheville dismissed a lawsuit filed by three couples​, two gay and one interracial. The judge ruled that the couples lacked legal standing as taxpayers to sue and lacked evidence showing they were harmed directly by the law taking effect in June 2015. Still, U.S. District Judge Max Cogburn wrote there is potential someone could suffer real harm because of the law.

The plaintiffs’ lawyers filed a notice Wednesday that they’ll appeal Tuesday’s ruling to the 4th U.S. Circuit Court of Appeals.

Get Breaking News Delivered to Your Inbox

North Carolina is one of only two states (the other being Utah) with such religious-objection laws that are being enforced. About 5 percent of North Carolina’s magistrates have filed recusal notices. In North Carolina, any official’s decision to opt out applies to all marriages - same-sex and heterosexual - for at least six months.

The law was pushed by Republicans and passed in mid-2015 over the veto of GOP Gov. Pat McCrory. Backers of the law said that it protects religious freedom and that government employees should be allowed religious accommodation if marrying same-sex couples runs counter to their beliefs.

The lawsuit focused primarily on the magistrate exception, arguing that it treats gay and lesbian couples differently, in violation of the equal-protection provision in the Constitution. The lawsuit also puts religious belief above the obligations of magistrates to carry out laws they swore to uphold, critics say.

The plaintiffs in the lawsuit included two same-sex couples. One of them, Kay Diane Ansley and Catherine “Cathy” McGaughey, helped overturn in court North Carolina’s 2012 constitutional ban​. The third couple, a white woman and black man, successfully sued in the mid-1970s when Forsyth County magistrates refused to marry them on religious grounds, according to the lawsuit.