A Missoula ordinance requiring background checks for most gun sales and transfers in the city limits is legal under state law, a District Court judge ruled Thursday, dealing a setback to the Montana Attorney General's Office, which had argued otherwise.

The city adopted the ordinance on an 8-4 vote in 2016 after City Attorney Jim Nugent determined that state law grants local governments the power to adopt background checks as a means to keep “convicted felons, adjudicated mental incompetents and illegal aliens” from acquiring a gun.

While the city argued it had the self-governing authority to enact the ordinance, the measure was quickly overturned by Attorney General Tim Fox, who deemed it illegal under state law.

District Court Judge Robert "Dusty" Deschamps disagreed with Fox's determination.

“The Attorney General's failure to recognize the law's presumption in favor of the power of local governments like Missoula's is erroneous,” Deschamps found. “The power possessed by the city in enacting the ordinance 'is not an expansive reading of the statute, but one that is taken from the clear meaning of the language used.'

“The court finds that, by invalidating the city of Missoula's ordinance, the Attorney General's opinion deprived Missoula of its own authority.”

In an amicus brief filed by the NRA on July 31, the powerful lobby suggested it would be difficult to think of a firearm regulation that Missoula could not enact if granted the authority to regulate background checks on gun sales and transfers within its own jurisdiction.

The court found that argument “highly speculative.”

“According to the NRA, 'To really keep guns out of the hands of felons, then perhaps the solution is to ban possession of firearms by everyone,' ” the judge wrote, quoting the NRA. “The court finds these premonitions dubious at best.”

The court also pointed to an amicus brief filed on behalf of the city by four Missoula residents, including Tom Platt, Mark Grimes, Heidi Kendall and John Moffat, who suggested the ordinance was a 'reasonable, common-sense' measure.”

“These individuals point out that 'firearms are an important part of Montana's rich culture,' ” the court wrote. “The ordinance was enacted specifically to further that goal in the interest of public safety and is a lawful exercise of local government power expressly supported by the plain language of (Montana law).”

City Council member Bryan von Lossberg, the primary sponsor of the ordinance, found that portion of the court's decision moving.

“It's arguably the most important part of it,” he said Thursday evening. “It gets to the point that this isn't an anti-gun sort of thing. Those folks in the amicus brief were both gun owners and not gun owners, and they all have shared values around the ordinance being a common-sense approach the city is clearly empowered to do.”

John Barnes, a spokesperson for the Attorney General's Office, said the state will either seek an immediate appeal to the Montana Supreme Court, or ask District Court to reconsider its decision after it receives the AG's brief, which was due Monday but hasn't yet been filed.

It wasn't immediately known if the court's decision served to reinstate the city ordinance immediately, or when it would take effect. Von Lossberg deferred that question to city's attorneys, who weren't immediately available for comment Thursday night.

The next step in the case could be the Montana Supreme Court.

“It's very affirming of what we've said from the beginning,” Von Lossberg said. “This is a common-sense measure that doesn't infringe on people's rights and promotes public safety in the community.”