SAN FRANCISCO (AP) — A suspected drunk driver accused of fatally shooting the California police officer who pulled him over was captured Friday as he tried to flee back to Mexico, where he lived before illegally crossing into the U.S., authorities said.

The sheriff whose agency was leading the investigation blamed California’s sanctuary law for preventing local authorities from reporting Gustavo Perez Arriaga’s previous arrests to federal immigration officials. If the suspect had been deported, he said, Cpl. Ronil Singh of the tiny Newman Police Department would still be alive.

“We can’t ignore the fact that this could have been preventable,” Stanislaus County Sheriff Adam Christianson said, asking why the state was “providing sanctuary for criminals (and) gang members. It’s a conversation we need to have.”

Following a statewide manhunt, Perez Arriaga was arrested on a murder warrant in a house near Bakersfield, about 200 miles (320 kilometers) southeast of the scene of the shooting.

As a SWAT team prepared to raid the house, Perez Arriaga came out with his hands up and surrendered. He was taken back to Stanislaus County in the slain officer’s handcuffs, Kern County Sheriff Donny Youngblood said.

Perez Arriaga crossed the border in Arizona several years ago and had worked a variety of jobs as a laborer, including at several dairies. He also had two prior arrests for driving while intoxicated, Christianson said.

The 33-year-old Mexico native had gang affiliations and multiple Facebook pages with different names, the sheriff said.

The shooting on Wednesday came amid an intense political fight over immigration, with President Donald Trump and congressional Democrats at odds over funding for a border wall that has forced a partial government shutdown.

Trump tweeted about Singh’s killing Thursday, saying it was “time to get tough on Border Security. Build the Wall!”

The sanctuary law limits cooperation between local law enforcement and federal immigration authorities, although it includes more than 800 exceptions for violent crimes and felonies. It also bars police from asking people about their citizenship status.

Former state Sen. Kevin de Leon, the Democrat who wrote the legislation, said it’s unfair to blame the law for the officer’s death.

Christianson said his department was prohibited by the law from sharing the suspect’s gang affiliations, “other active warrants” and past drunken driving arrests with federal immigration authorities. He did not specify the nature of the other warrants. De Leon said that suggests law enforcement could have apprehended Arriaga previously.

“He should’ve been in the physical custody of law enforcement,” de Leon said. To blame the law “is highly irresponsible.”

Neither Gov. Jerry Brown, who signed the law last year, nor Attorney General Xavier Becerra, who defended it in court, immediately responded to a request for comment. Brown has said the law strikes a balance between protecting families while ensuring consequences for serious criminals.

A federal judge upheld the law earlier this year in the face of a challenge from the Trump administration.

Christianson spoke at a news conference about the need to make laws stricter as Singh’s brother wept beside him.

Authorities also arrested five other people, including the suspect’s brother, 25-year-old Adrian Virgen, and a co-worker, 32-year-old Erik Razo Quiroz, who lied to police to try to protect him, Christianson said. He said both men were also in the country illegally.

Three people were also arrested at the home, Youngblood said.

Singh, 33, was an immigrant too, arriving legally from his native Fiji to fulfill his dream of becoming a police officer, authorities said. He had a newborn son and joined the 12-officer Newman police force in 2011.

“He came to America with one purpose, and that was to serve this country,” Newman Police Chief Randy Richardson said, choking up. He called Singh an “American patriot.”

Singh, the department’s first officer to die in the line of duty, drove more than two hours each way to attend the police academy in Yuba City, Richardson said. He joined the Merced County sheriff’s office as a reserve officer and worked as an animal control officer in Turlock before being hired by the Newman force in 2011.

English was Singh’s third language. He had a thick accent but took speech classes to improve his communication, the chief said.

___

Associated Press writers Daisy Nguyen in San Francisco, Amanda Lee Myers in Los Angeles and Kathleen Ronayne in Sacramento contributed to this report.