RICHMOND — The Virginia Senate on Wednesday passed a "red flag" law that would allow authorities to temporarily seize the firearm of someone deemed a threat, a measure that was strongly opposed by gun rights advocates who swarmed the streets around the state Capitol on Monday.

The bill passed on a party-line vote of 21-19, with every Democrat in favor and every Republican against. Debate grew unusually sharp as some GOP senators suggested that the bill would violate the Second Amendment’s right to bear arms.

“Each legislator that votes in favor of this bill in my opinion is a traitor to Virginia, a traitor to the Second Amendment and a traitor to our constitutional freedoms,” said Sen. Amanda F. Chase (R-Chesterfield), the gun-toting iconoclast known for her provocative style.

Sen. Janet D. Howell (D-Fairfax) threatened to write a formal complaint against Chase for violating Senate rules against “speaking offense” to members. “I am deeply offended,” Howell said, adding that she would hold off in her complaint only because Chase admitted she had not read the rules.

Other Republican senators tried to dial back the heat but argued that they felt the law was dangerous because it allowed police to seize weapons from someone based only on a civil complaint, not for breaking the law.

“I’m not going to invoke any highflying rhetoric,” Sen. Mark D. Obenshain (R-Rockingham) said after Chase’s outburst. “I think we’re all about trying to keep Virginia safer. However we have very differing views” on how to do it.

Opponents also argued the bill would put police officers into risky situations by having them confront someone who might not want to surrender their weapons. Sen. A. Benton Chafin Jr. (R-Russell) invoked the specter of Ruby Ridge, the Idaho compound where federal marshals got into a gun battle with a barricaded family group.

Chafin warned that “bloodshed . . . will occur as a result of this bill.”

The bill was among four gun control measures that passed out of a Senate committee last week. The other three — limiting handgun purchases to one per month, requiring background checks on all firearms purchases, and letting localities ban weapons from certain events and government buildings — have already passed the Senate.

The red-flag bill, which establishes what’s known as an extreme risk protective order, moved more slowly through the full Senate as members of both parties worked to address concerns about how the law would be implemented. Both Minority Leader Thomas K. Norment Jr. (R-James City) and Lt. Gov. Justin Fairfax (D) had urged senators to build more due process into the measure.

Amendments were included to require law enforcement agencies to consult with a commonwealth’s attorney before requesting a protective order and to require an affidavit of supporting facts, among numerous other tweaks.

“This is a clear improvement,” the bill’s chief sponsor, Sen. George L. Barker (D-Fairfax), said before the vote. “We’re going to continue to listen . . . [and] we may make further changes throughout the process.”

The bill will next go to the House of Delegates, which has yet to take up its own red-flag proposal or other gun-control bills that have been advocated by Gov. Ralph Northam (D).

Two days after tens of thousands of protesters thronged downtown Richmond to rage against gun control, Democrats said they were undeterred in seeking gun restrictions, which they said voters overwhelmingly endorsed by electing them last fall.

“We are headed in a positive direction with this legislation, which will protect lives and reduce violence in Virginia,” Barker said.

A Senate committee spent Wednesday afternoon taking up dozens of bills related to gun violence. The panel killed a series of Republican-backed measures to increase mandatory-minimum sentences for gun law violations, an approach that Democrats said does not deter crime and simply increases prison population.

“They’re bad policy,” Sen. Scott A. Surovell (D-Fairfax) said.

A House committee struck down a similar slate of measures Tuesday.