BOULDER, Colo. — In the days before the vote, there was a dress rehearsal of sorts, testing how quickly city council members could duck behind the dais, which had been made bulletproof before the occasion.

“We talked through how to get out both of the doors behind the dais. We talked about how to find the exits,” Mayor Sam Weaver (D) said of the 2018 meeting when the city council here voted unanimously to ban assault rifles amid death threats and before an audience that included armed protesters.

“So it was clearly more than just theoretical at that point,” Weaver said. “It was probably the most intense piece of council work I have ever done.”

The night this city banned assault weapons provides a vivid, frightening example of how hard corralling gun ownership and mass shootings has been in Colorado, where the killings at Columbine High School in 1999 and a movie theater in Aurora 13 years later have proved that gun violence here is far from theoretical.

And like much of Colorado’s history with gun control, which tracks the grim mile markers of the nation’s mass shootings, the step to ban assault rifles was legally fraught, followed a recent gun-related tragedy and ultimately did little to prevent the next one, which unfolded Monday in the aisles of a King Soopers grocery store here, where authorities say a 21-year-old armed with an AR-15-style firearm killed 10 people.

A state court overturned Boulder’s assault weapons ban just days before Ahmad Al Aliwi Alissa, who appeared in court on 10 murder charges for the first time Thursday and will be held without bail pending trial, allegedly traveled a half-hour from his home to carry out the killings.

Law enforcement officials have not disclosed where he acquired the Ruger AR-556 within a week of the shooting. Nor have Boulder’s elected leaders directly blamed the ruling that lifted the assault weapons ban for the tragedy.

But the shooting has revived questions across Colorado about gun ownership and the rights of cities, whose prevailing politics sometimes lie outside those of the state, to make their own laws for reasons of public safety. In the days since the shooting, Boulder officials and the city’s representatives to the state legislature have called for immediate action on a statewide assault weapons ban and the lifting of the state law prohibiting cities from regulating gun ownership.

“I’m not going to pretend that if that law wasn’t struck down, this wouldn’t have happened,” said state Sen. Stephen Fenberg (D), the chamber’s majority leader, whose district includes Boulder. “But it doesn’t mean it shouldn’t be addressed.”

For decades, Boulder has been in the liberal vanguard of same-sex marriage, marijuana legalization and the “sanctuary city” movement, which seeks to protect undocumented migrants and refugees from federal immigration authorities.

The attack on a King Soopers grocery store in Boulder, Colo., is the latest in a state that has been disproportionately plagued by the gun violence epidemic. (Luis Velarde/The Washington Post)

Like cities such as Berkeley, Calif., and Takoma Park, Md., it forges its own foreign policy, forming a view of how the world should work that differs at times from the outlook in the more conservative state around it. In Colorado, a city’s right to make its own laws and impose its own taxes is called “home rule,” a status Boulder has.

The side-by-side mix of liberal enclaves and frontier communities that fervently oppose any move to limit gun and ammunition ownership has become a common feature of the American West. But it has been this city’s go-it-alone work on gun-control measures that has drawn the most opposition in a state where gun rights are often described as the “third rail” of Colorado politics.

Boulder council members acknowledge that when they passed the assault weapons ban, they knew they were violating state law that “preempts” cities’ regulating gun ownership. The council acted after the mass shooting at a high school in Parkland, Fla., in February 2018, when a gunmen used an assault rifle to kill 17 people, most of them students.

“The suit speaks for itself,” Robert Chambers, a plaintiff in the lawsuit opposing the city’s assault weapons ban, said when reached this week by phone. “I have nothing else to say about it.”

The state passed its preemption law prohibiting a city’s right to regulate gun ownership in 2003, four years after a pair of gunmen killed a dozen students and a teacher at Columbine High School, about 40 miles southeast of here. The law exempted the state capital, Denver, which passed its own assault weapons ban more than a decade earlier, and that remains in place today.

In theory, the legislature passed the law to end the inconsistency over where in the state it was possible to own an assault-style weapon and where it was not, a patchwork of rules that left law enforcement agencies, as well as gun owners, confused.

But the legislature did not worry as much about consistency on other issues, including marijuana legalization in the years before Colorado voters decided in 2012 to make recreational sales and use legal.

“Both parties are hypocritical all the time on this issue,” said David Kopel, a professor at the University of Denver’s Sturm College of Law, who spoke against Boulder’s assault weapons ban at the time it was passed. “The natural norm across the country, though, is preemption on the gun issue.”

Fenberg, who in a virtual town hall this week said “now is the time to act and the time to be angry,” had been working on legislation to lift the state prohibition on cities making gun regulations before the judge’s ruling that blocked Boulder’s assault weapons ban. His efforts have gained momentum since the shooting on Monday.

“We are not changing state law other than saying a local government can regulate firearms,” Fenberg said. “We are a local-control state — our entire public school system basically is local control. So it’s not uncommon that we pass laws or have long-standing laws on the books that allow local governments to do these types of things.”

Colorado has turned more Democratic in recent years, in part because the state Republican Party did not support former president Donald Trump as avidly as some of its neighbors. Democrats control both houses of the state legislature, and the governor, Jared Polis, is a Democrat born and raised in Boulder.

There are other reasons to think that Colorado may take more-decisive action against assault rifles in the aftermath of the King Soopers shooting.

The once-potent gun lobby, which after the Colorado legislature’s 2013 vote to ban high-capacity magazines following the Sandy Hook Elementary School shooting in Connecticut managed to recall a pair of state senators and force another to resign, is now fractured over tactics and ideology.

And two years ago, the legislature passed a “red flag” law enabling law enforcement to take guns away from people deemed to be a threat to themselves or to others. The vote was viewed here as a sign that some gun-control regulation is possible in the current political environment.

In his virtual town hall two days after the shooting, Fenberg said that defending the Boulder assault weapons ban is “top of mind” as the case works its way toward the Colorado Supreme Court.

“But it can’t end there,” he said. “We know that it alone is woefully inadequate to protect our communities.”

On that May evening in 2018, the council chamber here was awash in color. Those in the audience wearing red were affiliated with “Moms Demand Action,” an organization advocating for more-restrictive rules on gun ownership. Those in orange — some of whom were armed, according to council members there that night — opposed the ban.

Weaver, who identifies himself as a gun owner, said he had been receiving unsigned postcards at his home address in the weeks leading up to the vote. The cards showed Weaver in the crosshairs of an AR-15, an assault rifle that would be banned under the ordinance being considered.

The council had previously considered a ban. But after the Parkland shooting, an issue that had been largely dormant was brought back by Jill Grano, a then-council member who wrote in an email to the public at the time that “the Second Amendment is the only amendment in the Bill of Rights that includes the words ‘well regulated,’ yet nationally the right to bear arms is one of the least regulated among our constitutional rights.”

“We anticipate that this will be an intensive community conversation,” she added.

Despite the unanimous vote for the assault weapons ban, a lawsuit soon followed. Weaver and others say it was funded by gun rights groups, although Chambers, one of the plaintiffs, declined to comment on who paid for the case.

Weaver said nearly all of Boulder’s legal defense has been provided free by law firms interested in gun control.

“My heart is broken,” said Grano, who resigned from the council to work for Rep. Joe Neguse (D-Colo.), who received undergraduate and law degrees from the University of Colorado at Boulder. “We tried so hard to prevent this from happening, yet here we are.”