HELENA, Mont. (AP) — The Montana Supreme Court on Tuesday struck down a Missoula city ordinance requiring background checks on all gun sales in the city, ruling that it goes against a state law prohibiting restrictions on gun sales.

The five-justice panel ruled unanimously that the ordinance, the first of its kind in Montana, is barred by a law that says local governments are not allowed to exercise any power that “affects the right to keep or bear arms.”

The decision overturns a ruling by a district judge who said the ordinance complies with another section of state law that allows local governments to enact rules to keep felons, the mentally ill, minors and people illegally in the U.S. from possessing weapons.

ADVERTISEMENT

The high court ruled the Missoula ordinance went too far by subjecting every private gun sale to a background check.

“It regulates ... everyone who engages in a transaction with a private, unlicensed dealer,” Justice Jim Rice wrote in the opinion.

Federal law requires background checks on gun purchases from licensed sellers, such as gun stores, but not on private sales.

The ruling upholds a previous opinion by Attorney General Tim Fox, who said in a statement that he was confident his position would be vindicated.

“Missoula’s ordinance is unenforceable,” Fox said. “The rule of law and Montana’s constitution matter.”

The city passed the ordinance in 2016, with officials saying additional background checks close a loophole that allows people who aren’t allowed to own firearms to buy them.

Fox issued his advisory opinion a few months later at the request of then-House Speaker Austin Knudsen, an opinion that had the power of law until it was overturned by District Judge Robert Deschamps.

Bryan von Lossberg, Missoula’s city council president and the sponsor of the ordinance, said he was “deeply saddened and disappointed” by the ruling.

“Background checks save lives,” he said. “The ruling highlights the unfortunate aspect of pre-emption laws that prevent a city like Missoula and its elected officials from deploying a proven policy tool.”

The Republican-led state Legislature placed a referendum on the 2020 election ballot that would repeal parts of state law that Missoula city officials cited as justifying the ordinance.

The measure, if voters approve, would eliminate cities’ and towns’ ability to regulate concealed weapons and restrict weapons carried at public assemblies, in parks and in schools.