HELENA, Mont. — The city of Missoula sued Montana’s attorney general Wednesday in an attempt to move ahead with plans to expand background checks to include private gun sales in the city.

The lawsuit, filed in Missoula County District Court, asks a judge to overrule Attorney General Tim Fox’s opinion that Missoula’s background check ordinance is prohibited by state law.

Fox’s opinion has the power of law unless a court overturns it, meaning the city has not had the ability to enforce the ordinance.

The city passed its ordinance in September 2016 requiring background checks on gun purchases from private, unlicensed sellers — the only one of its kind in the state. Federal law already requires background checks on gun purchases from licensed sellers, such as gun stores.

Fox, a Republican, issued his advisory opinion in January 2017 at the request of Montana House Speaker Austin Knudsen, R-Culbertson. Fox wrote that the ordinance oversteps a state law that denies local governments any power that “affects the right to keep or bear arms.”

An exception is that local governments can regulate the carrying of concealed weapons.

“This dragnet approach on all gun sales or transfers within the City of Missoula’s borders ignores the long-standing statutory provisions,” Fox wrote in the advisory opinion.

The city’s lawsuit asks a judge to issue a ruling that says Fox is wrong, that the city ordinance is valid and enforceable, and not pre-empted by any state law.

City officials said the ordinance would close a loophole that allows people who aren’t allowed to own firearms to buy them, such as convicted felons.

“It does not apply to or affect the right to keep or bear arms, much like the federal background check requirement does not implicate the right to keep and bear arms,” wrote Scott Stearns, an attorney representing the city.

Fox spokesman Eric Sell said he didn’t have a comment on the lawsuit.

The gun safety advocacy group, Moms Demand Action, called the city ordinance a “common-sense public safety measure.”

“Missoula’s leaders know we don’t have to choose between supporting the rights of law abiding gun owners and closing dangerous gaps in our gun laws, and they have our strong support as they work to prevent gun violence in our great city,” said Pamela Owen, a spokeswoman for the group’s Montana chapter.