The Washington state Supreme Court upheld Seattle's gun and ammunition tax in an 8-1 ruling Thursday morning.

The city passed legislation in 2015 to charge gun shops $25 for every gun sale and a nickel for every round of ammunition, projecting that it would raise up to $500,000 a year for gun violence prevention programs. But in 2016, it raised less than $200,000, according to The Seattle Times.

The National Rifle Association was among those suing the city, arguing the tax is illegal because Washington state prohibits local governments from adopting laws related to firearms unless those local ordinances are specifically authorized. But the city said the measure is within its taxing authority.

The majority opinion, written by Justice Debra Stephens, determined the ordinance is not unconstitutional, saying it "imposes a tax because its primary purpose is to raise revenue for the public benefit. That tax is specifically authorized under RCW 35.22.280(32), which grants first class cities broad tax powers, including the authority to levy a flat tax on gun sales."

In a concurring opinion, Justice Steven Gonzalez wrote "The record does not contain evidence that the City intended for this "tax" to be a regulation or that this "tax" had a significant regulatory effect."

The lone dissenter was Justice Sheryl Gordon McCloud.

"RCW 9.41.290' s plain language demonstrates clear legislative intent to preempt local 'laws and ordinances' that 'relat[e] to firearms' as broadly as possible. A city tax that singles out the sale of firearms and ammunition for disadvantageous treatment is therefore preempted," wrote McCloud.

The Associated Press contributed to this report.