A judge upheld Seattle's so-called gun violence tax on Tuesday, rejecting a challenge from the National Rifle Association and other gun rights groups.

King County Superior Court Judge Palmer Robinson dismissed arguments that Seattle's tax, adopted this summer, exceeded the city's authority under state law.

The measure — a rarity of its kind in the U.S. — adds $25 to the price of each firearm sold in the city, plus 2 or 5 cents per round of ammunition, depending on the type. Officials expect it to raise up to $500,000 a year to help offset the costs of gun violence. The measure is set to take effect next month.

The NRA; the Second Amendment Foundation, based in Bellevue, Washington; the National Shooting Sports Foundation; two gun owners; and two gun shops sued Seattle in August, calling the ordinance "a piece of propaganda."

"The NRA and its allies always oppose these common-sense steps to shine light on the gun violence epidemic," said City Council President Tim Burgess, who sponsored the law. "Judge Robinson saw through the NRA's distorted efforts to put gun industry profits ahead of public safety."

The NRA vowed to appeal the ruling, reported The Seattle Times. "It’s unfortunate the court choose to ignore the law and embrace the Seattle City Council’s anti-gun agenda," the group's spokesman Lars Dalseide said in a statement. The Second Amendment Foundation also promised an immediate appeal.

The groups have argued state law puts responsibility for regulating firearms solely in the hands of the state legislature, not local governments. The Second Amendment guarantees the right to bear arms.

"It is unconscionable for Mayor Ed Murray and the City Council to codify what amounts to social bigotry against firearms retailers and their customers," Second Amendment Foundation founder Alan Gottlieb said in a written statement.

But the judge found the measure falls within the city's taxing authority and is not an impermissible regulation.