California lawmakers approved legislation on Thursday to impose a new tax on firearms and ammunition sales to help finance gun-violence prevention and education programs, a victory for Democrats after years of failing to pass similar measures.

The legislation, Assembly Bill 28, would impose an 11% tax on dealers and manufacturers for sales of guns and ammunition, and is one of a small number of major gun control measures still moving through the Legislature this year. It’s the first time that Democrats have successfully sent a firearms tax proposal to the governor.

While Gov. Gavin Newsom has rejected or expressed resistance to imposing new taxes, he also has signed into law dozens of gun control measures. And after several mass shootings in schools across the country and two high-profile massacres in Half Moon Bay and Monterey Park this year sparked fresh outrage from advocates, lawmakers are under pressure to strengthen gun control in California, even as new laws face legal scrutiny and are often rejected by the courts for being unconstitutional.

Assemblymember Jesse Gabriel, an Encino Democrat and author of the bill, estimates that it could generate roughly $160 million annually for violence prevention and school safety programs and victim-support services.

Gabriel said the funding for the programs included in this year’s bill helped convince a handful of his more moderate Democratic colleagues to support the measure and ensure it landed on Newsom’s desk, despite political risks associated with voting for tax increases.

“People can feel really comfortable that we are spending money in ways that are going to move the needle on gun violence,” said Gabriel, who is also the chair of the Legislature’s Gun Violence Prevention Working Group.

If signed into law by the governor, the proposal would set aside $75 million for city- and community-based gun violence prevention programs, $50 million for school safety and also add millions in new funding for law enforcement to remove firearms from those convicted of domestic violence or who have restraining orders against them. It would also set aside a small amount for counseling and trauma services for victims of mass shootings and gun violence.

“Gun violence is the leading cause of death for kids in the United States,” said state Sen. Anthony Portantino (D-Burbank). “Ending that should be bipartisan. … We should stand on the right side of history.”

The bill narrowly cleared the two-thirds vote requirement in both houses of the Legislature necessary to raise taxes. The Senate approved it 27 to 9 and the Assembly by 54 to 17, with Republicans opposing and several Democrats withholding their vote. Gun rights groups, along with conservation, wetlands and wildlife advocacy organizations, opposed AB 28.

“It’s ineffective. It’s not going to do anything to curb gun violence. It’s not going to get illegal guns off the street,” state Sen. Kelly Seyarto (R-Murrieta) said during a Senate debate.

State Sen. Bill Dodd, a Napa Democrat who did not vote for the bill, said his more rural district included tens of thousands of licensed gun owners “whose voices have not been heard” and who he said will ultimately bear the tax burden.

“I support these programs wholeheartedly. They need to be funded,” Dodd said. “I think we need to be careful of how we fund them and who we target.”

If signed, the new tax would go into effect on July 1, 2024.