The memory of a mass shooting that killed three at the Gilroy Garlic Festival was still fresh in nearby San Francisco when its Board of Supervisors unanimously voted last week to denounce the National Rifle Association. But the city’s leaders took their message a step further, declaring on Sept. 3 that the NRA is a “domestic terrorist organization” and discouraging the city from working with contractors or vendors with ties to the gun rights lobby.

Now the NRA is hitting back with a lawsuit that calls the resolution “obviously unconstitutional,” arguing that targeting gun-friendly vendors and contractors violates their right to free speech.

“This lawsuit comes with a message to those who attack the NRA: we will never stop fighting for our law-abiding members and their constitutional freedoms,” NRA CEO and executive vice president Wayne LaPierre said in a statement shared with The Washington Post.

The San Francisco City Attorney’s Office responded by suggesting the NRA focus on reducing gun violence.

“The American people would be better served if the NRA stopped trying to get weapons of war into our communities and instead actually did something about gun safety,” John Coté, a spokesman for the San Francisco City Attorney’s Office, told the Associated Press. “Common-sense safety measures like universal background checks, an assault weapons ban, and restricting high-capacity magazines would be a good start.”

The legal battle comes as legislators nationwide grapple with how to address gun violence after a summer marked by mass shootings in California, Texas and Ohio. It also comes at a time of turmoil for the NRA, which has lost a president, its top lobbyist and several board members amid financial woes, and as public opinion swings in favor of stricter gun laws, even among Republicans. Last week, Walmart announced it will stop selling ammunition for military-style weapons and asked customers to refrain from openly carrying guns into stores.

San Francisco passed the resolution after a gunman killed a 6-year-old, 13-year-old and 25-year-old in Gilroy, about 80 miles south of the city, on July 28. Supervisor Catherine Stefani, who wrote the resolution, told The Washington Post she believes the NRA deserves to be known as a “terrorist organization.”

“They should reasonably know by now that they are fueling the hate fire in this country,” she said after the resolution passed. “People are dying, and they continue to stand in the way of reform.”

In the resolution, the Board of Supervisors also urged the city to review its relationship with companies that work with the NRA and refrain from establishing new partnerships with any business that supports the gun lobby.

“The National Rifle Association through its advocacy has armed those individuals who would and have committed acts of terrorism,” the resolution says. “All countries have violent and hateful people, but only in America do we give them ready access to assault weapons and large-capacity magazines thanks, in large part, to the National Rifle Association’s influence.”

In a lawsuit filed Monday in U.S. District Court for the Northern District of California, the NRA says that the “terrorist” label is little more than a “frivolous insult.” Instead, the suit primarily takes issue with the Board of Supervisors’ attempts to bar the city from working with NRA-connected vendors and contractors.

“San Francisco’s actions pose a nonfrivolous constitutional threat,” the lawsuit argues. “Defendants are intent on targeting the NRA for its advocacy, chilling the NRA’s and its members’ rights of free speech and association under the First Amendment, all with an eye to silence the NRA from the debate on Second Amendment rights.”

The NRA also cites recent examples of critics pushing back against the “terrorist” label, pointing to a Los Angeles Times opinion piece by Michael McGough, who argued that the NRA “richly deserves criticism for its role in preventing the enactment of sensible gun-control legislation” but called the resolution “problematic from a 1st Amendment perspective.”

Although the “terrorist” label was panned by conservative politicians and commentators, some legal scholars noted that the government is allowed to dish out insults.

“The government can say whatever it wants and its speech cannot be said to violate the First Amendment,” Professor Erwin Chemerinsky, dean of Berkeley Law at the University of California, said in an email to The Post. “The law is clear on that.”

Other legal experts took exception to the terminology. Jonathan Turley, a constitutional law professor at George Washington University, argued in the Hill that the Board of Supervisors “took one step too far” in labeling the NRA “terrorists.”

“San Francisco is declaring that advocacy of a constitutional right is akin to being an arm of the Islamic State,” Turley writes.

The second piece of the resolution, which restricts the city from engaging in business with NRA-supporting contractors and vendors, might violate the First Amendment, Chemerinsky acknowledged — but only if the city enforces that rule.

“The government cannot punish people for their political views,” he said. “But at this stage, it is too general a threat to be ripe for review.”

Although the resolution hasn’t taken effect yet and still must be signed by the San Francisco mayor by Saturday, the NRA’s lawsuit claims the threat of enforcement is enough to chill free speech.

“This action is an assault on all advocacy organizations across the country,” NRA attorney William A. Brewer III said in a statement. “Fortunately, the NRA, like all U.S. citizens, is protected by the First Amendment.”