RICHMOND — A bill banning the sale of assault-style weapons and possession of high-capacity magazines cleared a House committee Friday, drawing such an angry reaction from gun rights activists that the panel’s chairman had Capitol Police clear the room.

Sponsored by Del. Mark H. Levine (D-Alexandria), the measure would prohibit the sale or transfer of those firearms beginning July 1, and outlaw possession of the magazines six months later, on Jan. 1, 2021.

The legislation initially would have banned all possession of assault weapons, forcing owners to give them up. But the House Public Safety Committee modified it to prohibit only sales and transfers. Anyone who legally owned those guns before the law took effect would be allowed to keep them.

The measure takes a harder line on magazines that hold more than 12 rounds and on bump stocks, banning their sale and possession. Bump stocks, attachments that make a gun fire more rapidly, are already subject to a federal ban.

The bill is perhaps the most controversial part of an eight-bill package of gun-control legislation that Gov. Ralph Northam (D) backed after a shooter killed 12 people in a Virginia Beach municipal building on May 31.

The possibility of an assault weapons ban sparked fears across Virginia that newly empowered Democrats, who won majorities in both the House and the Senate last fall, were planning to confiscate guns.

“As an army doctor, Governor Northam has seen firsthand what weapons of war do to a human body,” his spokeswoman, Alena Yarmosky, said in a statement. “This bill will save lives in Virginia, and the Governor is glad to see it advance.”

Democrats won their majorities on a promise to enact sweeping gun control, including universal background checks and a purchase limit of one handgun a month.

Since the election, more than 110 Virginia counties, cities and towns have passed some type of “Second Amendment sanctuary” resolution, many of them asserting that local officials will not enforce laws they consider unconstitutional. Gun rights activists staged an enormous rally on Capitol Square last month, drawing heavily armed militias from across the country.

The changes to Levine’s bill did little to satisfy gun rights activists, who complained that the ban on extended magazines would criminalize possession of items they had legally purchased. After the committee approved the measure on a party-line 12-to-9 vote, some in the hearing room chanted, and one man yelled the state motto — “Sic semper tyrannis,” or “thus always to tyrants.”

Committee Chairman Patrick A. Hope (D-Arlington) then asked police to clear the room.

“This egregious gun ban is designed to make millions of law-abiding Virginians felons overnight,” National Rifle Association spokeswoman Catherine Mor­tensen said in an email. “Lawmakers have delayed bringing up this gun ban because voters from across the Commonwealth oppose it.”

While most of the gun-control measures backed by Northam are sailing through the legislature on party-line votes, the fate of the assault weapons bill in the full House is uncertain; at least a few Democratic delegates voiced concern about the original version earlier this year.

The measure would also have to clear the Senate, where Majority Leader Richard L. Saslaw (D-Fairfax) last month scrapped his own assault weapons bill, which was not part of Northam’s package and would have banned possession of those firearms.

“Your colleagues don’t want this bill, on both sides — it’s the majority, the minority, the other chamber. Nobody wants this bill,” D.J. Spiker, the NRA’s state director for Virginia, testified to the committee.

Brian Moran, Northam’s secretary of public safety and homeland security, urged the committee to back the bill.

“Assault weapons are not protected by the Second Amendment because they’re weapons of war. . . . They’re not protected, just like machine guns before them,” he said. “The court will uphold this legislation. You just need to pass it.”

The House has approved the governor’s other seven gun-control bills, which would:

●Enact universal background checks on private gun sales.

●Require an owner to report the loss or theft of a firearm within 24 hours.

●Give local governments the authority to enact gun laws of their own, such as banning weapons in public buildings.

●Create a “red flag” law, or extreme risk protective order, under which authorities can temporarily seize firearms from someone deemed a threat to themselves or others.

●Limit handgun purchases to one per month, a policy that was in effect in Virginia until 2012.

●Tighten the law prohibiting access to firearms for someone subject to a protective order.

●Make it a felony to “recklessly” leave a firearm within reach of anyone age 18 or younger, up from the current age of 14, a measure known as “child access prevention.”

The Senate, which has no assault weapons bill of its own, has passed five of the governor’s bills. The Senate’s bill on lost or stolen firearms is expected to get a vote on the floor next week. Its version of the child-access prevention bill died in committee, with Democratic Sens. Chap Petersen (Fairfax City) and R. Creigh Deeds (Bath) joining Republicans in opposition.