SACRAMENTO, Calif. — An emotional debate over balancing the lives of residents and officers led to a key approval Wednesday of California legislation intended to deter deadly police shootings — rules that advocates said would be among the most sweeping in the U.S. when tied to a related measure on officer training.

The California Assembly approved the legislation 67-0 after changes last week ended what had been vehement opposition from law enforcement. The measure now goes to the Senate.

It would allow police to use deadly force only when it is “necessary” to defend against an imminent threat of death or serious injury to officers or bystanders. It was sparked by public outrage over fatal shootings by police, including the killing of unarmed vandalism suspect Stephon Clark in Sacramento last year.

“This bill will only work because of the buy-in from the communities as well as from law enforcement,” said Democratic Assemblywoman Shirley Weber of San Diego, who wrote the measure. “Police officers should never take a human life when there are alternatives. AB392 is about preventing unnecessary deaths.”

WATCH: @AsmShirleyWeber 's powerful closing remarks on #AB392, which just passed the Assembly floor. This bill would change the legal standard on use of deadly force by law enforcement officers. #caleg pic.twitter.com/fU7I33o8OL — Assembly Democrats (@AssemblyDems) May 29, 2019

The measure passed after 90 minutes of debate, including from lawmakers who said they or a loved one had been stopped because of their race or ethnicity.

“I went through ‘black driver training,’” said Democratic Assemblyman Reggie Jones-Sawyer of Los Angeles. “I still have that fear that I may not go home when those lights are behind me. But more importantly, law enforcement still has their fear that if they stop someone that looks like me, that they may not go home. We need to end that.”

Like lawmakers of both parties, he said changing the legal standard is only one step.

“We need to ensure those changes are implemented by committing resources to train officers in new policies and best practices,” Jones-Sawyer said.

The measure is linked to legislation approved Tuesday by the Senate that would require training for officers on ways to de-escalate confrontations, alternatives to opening fire and ways to interact with people with mental illness or other issues.

Republican Assemblyman James Gallagher Yuba City called the amended measure on when police can open fire “a reasonable compromise ... that protects the lives of officers and the lives of the public.”

No Republicans spoke overtly against it, although one questioned whether it significantly alters current standards and another said a key to avoiding unnecessary deaths is teaching people to respect and obey police.

Democratic Assemblyman Al Muratsuchi, a former prosecutor from Torrance, said the legislation will give California “one of the strongest standards in this country ... while making sure that we are not punishing our many law enforcement officers of good faith who are just going out every day trying to protect our communities and serve.”

Robert Weisberg, co-director of the Stanford Criminal Justice Center and an expert on use-of-force law, said the combined measures will improve police training. However, “the inclusion of this word ‘necessary’ doesn’t really change anything, because necessary is ... always going to be subject to court interpretation.”

That’s particularly true after amendments last week deleted an explicit definition of “necessary” that had said officers could open fire only when there is “no reasonable alternative.”

That change was key to law enforcement becoming officially neutral on the legislation because it effectively aligns with existing court decisions, said Brian Marvel, president of the rank-and-file Peace Officers Research Association of California and a top negotiator on the amended measure.

Amendments also removed what had been an explicit requirement that officers try to de-escalate confrontations before using deadly force, replacing it with what Weisberg called “some fuzzy language about exploring alternatives.”

That change also was also crucial because it deleted what Marvel said was essentially “a checklist before they could use lethal force,” subjecting officers to endless second-guessing of what often is a split-second decision.

Weisberg said the legislation brings California’s antiquated law in line with court rulings and other states on when officers can shoot a fleeing suspect, making it clear that the officer must reasonably believe the suspect is likely to cause death or serious injury unless they’re immediately caught.