SAN FRANCISCO (AP) — A man suspected of killing a California policeman was in the U.S. illegally and captured while planning to flee to his native Mexico, a sheriff said as he all but blamed the state’s sanctuary law for the officer’s death.

A two-day statewide manhunt ended Friday with the arrest of Gustavo Perez Arriaga, who came out with his hands up as a SWAT team prepared to raid a home in Bakersfield, about 200 miles (320 kilometers) southeast of where Cpl. Ronil Singh was shot before dawn Wednesday.

Singh had pulled over a suspected drunken driver in the small town of Newman when he was fatally wounded and managed to fire back but didn’t hit the attacker, authorities have said.

A resident who saw the driver get behind the wheel flagged down Singh and heard the gunshots minutes later, Stanislaus County sheriff’s Sgt. Tom Letras told the Modesto Bee newspaper.

Sheriff Adam Christianson, who led the investigation, blamed California’s sanctuary law for preventing local authorities from reporting Perez Arriaga to U.S. immigration officials for deportation after two previous drunken driving arrests.

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

Perez Arriaga crossed the border in Arizona several years ago and had worked a variety of jobs as a laborer, including at several dairies. The 33-year-old had gang affiliations and multiple Facebook pages with different names, Christianson said.

The shooting came as the political fight over immigration has intensified, 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!”

California’s statewide sanctuary law limits cooperation between local authorities and U.S. immigration officials and has drawn scorn from the Trump administration. It includes more than 800 exceptions for violent crimes and felonies and bars police from asking people about their citizenship status.

Gov. Jerry Brown has said the law strikes a balance between protecting families and ensuring consequences for serious criminals. His spokesman said Friday that if the suspect was a known gang member, police could have informed federal authorities.

“California law fully permits the sharing of information on dangerous gang members,” spokesman Evan Westrup said.

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

“The type of tone and attitude that Sheriff Christianson has taken instills fear and panic in all immigrant communities” that could make people afraid to report crimes, de Leon told KNX-AM radio in Los Angeles.

Authorities have arrested seven other people, including Perez Arriaga’s brothers, 25-year-old Adrian Virgen and 34-year-old Conrado Virgen Mendoza; his girlfriend, 30-year-old Ana Leyde Cervantes; and a co-worker, 27-year-old Erik Razo Quiroz, authorities said. Three people were arrested at the home near Bakersfield.

All are accused of helping Perez Arriaga, who’s expected to be arraigned on charges Wednesday, authorities said.

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

Newman Police Chief Randy Richardson called him a patriot.

“This is a man that loved his country. This is a man that worked hard for what he believed in. He believed in this community,” the chief said at a community vigil Friday night honoring Singh.

Hundreds of residents, friends, relatives and fellow officers attended the candlelight memorial, where many cried and some spoke emotionally about the officer.

“Ronil loved his job,” said Reggie Singh, holding his brother’s 5-month-old son.

___

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