SACRAMENTO — Civil liberties advocates are declaring victory after California became the latest state to block police from using facial recognition technology in body cameras.

Gov. Gavin Newsom signed AB1215 on Tuesday, prohibiting police departments from outfitting body cameras with technology to identify people through their facial features or other biometric traits. The law takes effect Jan. 1 and expires in 2023, but can be renewed.

State lawmakers passed the bill after Amazon’s Rekognition facial recognition software incorrectly identified 26 legislators as criminal suspects, including the assemblyman who carried the measure, San Francisco Democrat Phil Ting.

Ting said the test, conducted by the American Civil Liberties Union of Northern California using lawmakers’ photos, showed that the technology is error-prone and could lead to officers arresting innocent people.

“Let’s not become a police state,” Ting said after the bill passed the Legislature. He said officers’ body cameras should be used “as they were originally intended — to provide police accountability and transparency.”

Police and facial-recognition advocates say officers could use the technology as a red-flag system, to alert them if an image captured on a body camera matches that of a suspect or someone in an arrest database.

No police agencies in the state use the technology now, according to the California Peace Officers’ Association. But some departments have looked into it, and the technology is widely used in China and other countries.

The new law makes California the largest state to ban the software in body cameras. Oregon and New Hampshire have similar bans, and cities including San Francisco and Oakland have adopted more sweeping laws.

Ting’s bill originally called for a permanent ban, but he scaled it back to three years after the Peace Officers’ Association and several other law enforcement groups protested.

Police groups argued that banning the technology would take away a tool that could save departments time and money. They said the software could help identify criminals at large events.

“Prohibiting the use of biometric surveillance systems severely hinders law enforcement’s ability to identify and detain suspects of criminal activity,” the California Police Chiefs Association told lawmakers.

Critics of the technology, including the ACLU, said the software could lead police to violate civil-rights protections because many of the people it has incorrectly identified as suspects were people of color.

“Unleashing this inaccurate and racially biased technology on police body cameras ... would undoubtedly lead to unjust arrests and even death,” said Matt Cagle, technology and civil liberties attorney for the ACLU.

Dustin Gardiner is a San Francisco Chronicle staff writer. Email: dustin.gardiner@sfchronicle.com Twitter: @dustingardiner