The Washington state legislature passed a bill establishing new guardrails on government use of facial recognition software.

The bill cleared both chambers of the state legislature Thursday, hours before the session ended, positioning Washington as one of the first states in the nation to regulate facial recognition, a key component in the larger legal debate over artificial intelligence. The bill now awaits Gov. Jay Inslee’s signature.

The legislation requires public agencies to regularly report on their use of facial recognition technology and test the software for fairness and accuracy. Law enforcement agencies must obtain a warrant before using facial recognition technology in investigations unless there is an emergency. The bill also establishes a task force to study the use of facial recognition technology by government agencies.

Under the bill, public entities using facial recognition software to make decisions that produce “legal effects” must ensure a human reviews the results. That category includes decisions that could affect a person’s job, financial services, housing, insurance, and education.

“This is historic,” said state Sen. Joe Nguyen, the sponsor of the bill who also works for Microsoft. “I don’t know of any other jurisdiction, for sure in the United States, maybe in the world, where it requires the company to expose their underlying data … in a way that we can test it for accuracy.”

Washington is home to two of the largest companies in the nation developing facial recognition software: Amazon and Microsoft. Leaders at both companies have called on lawmakers to create new rules for facial recognition technology, which is largely unregulated.

Last September, Amazon CEO Jeff Bezos called facial recognition “a perfect example of where regulation is needed.” Microsoft President Brad Smith has repeatedly warned of the consequences of allowing the technology to continue to be deployed without guardrails. But Smith said in January that the temporary moratoriums on the technology that some governments are considering would be like using a meat cleaver instead of a scalpel.

Facial recognition has become a lightning rod, with civil rights groups and researchers claiming it can amplify human biases. Studies of Amazon’s Rekognition software, conducted by the ACLU and MIT, showed the technology misidentifies women and people of color more frequently than it does white men. Amazon says the methodology of those studies was flawed, and recommends a high confidence threshold for any law enforcement agency using the software.

The ACLU is pushing back on the deployment of facial recognition by local and federal government agencies. On Thursday the civil rights organization sued the federal government, demanding information on how immigration officials use facial recognition technology.

The bill that passed Thursday in Washington state was one of several attempts by lawmakers to rein in facial recognition. A separate bill focused on data privacy regulation included new rules for commercial applications of facial recognition technology, but that legislation did not pass before the deadline.