The NRA and two other advocacy groups have sued Seattle over its new gun tax.

The National Rifle Association filed the lawsuit in conjunction with the National Shooting Sports Foundation, a gun industry group based in Newtown, Connecticut, and the Second Amendment Foundation, a gun rights group in Bellevue near Seattle.

Two Seattle gun shops and two individual gun purchasers also joined in the suit, which was filed Monday.

Larry Keane, senior vice president and general counsel for the NSSF, said they filed the lawsuit after the Seattle mayor signed the tax into law Friday. He said that Seattle is violating a Washington state law that preempts a city's ability to pass its own gun control laws.

The new law imposes a $25 tax on every gun sold in Seattle, and a 5 cent tax on every bullet (or 2 cents on every bullet that's .22 caliber or less.) The city aims to raise $300,000 to $500,000 per year, to offset some of the cost of gun violence. Seattle estimates that taxpayers pick up $12 million of the annual $17 million in medical costs from gunshots.

"That's like putting a tax on a pharmacy to address a drug epidemic," said Keane. "The only difference is that purchasing a gun is a constitutional right."

Related: Gun violence costs U.S. taxpayers $500 million a year

The Seattle City Council unanimously passed the gun tax on Aug. 10 and it will go into affect January 1.

Council President Tim Burgess told CNNMoney that the city is not violating state law by taxing sales within Seattle.

"We're not attempting to control whether someone can purchase a weapon," he said. "We are taxing a commodity."

The lawsuit was filed on behalf of Seattle gun shops Outdoor Emporium and Precise Shooter, which would be caused "irreparable harm" by the tax.

Keane said the tax "is essentially trying to drive retailers out of business, to drive them out of town."