LOS ANGELES (Reuters) - A suspected illegal immigrant accused of shooting to death a California police officer was arrested on Friday after a two-day manhunt that President Donald Trump cited in his push for building a wall on the border with Mexico, officials said.

Gustavo Perez Arriaga, 32, a Mexican national, was arrested in Bakersfield, a city less than 200 miles (320 km) south of Newman where the officer was shot on Wednesday, Stanislaus County Sheriff Adam Christianson said at a news conference.

The shooting and manhunt in California’s agricultural Central Valley entered the national debate over immigration, after Trump tweeted about it in his advocacy for a border wall and Christianson criticized California’s sanctuary law for immigrants.

Arriaga is accused of shooting to death Newman police corporal Sonil Singh after Singh pulled him over on suspicion of driving under the influence.

The suspect, who exchanged fire with Singh, has claimed to be involved with a criminal gang called the Sureños and was trying to escape to Mexico, Christianson said.

On Friday, heavily armed police officers surrounded the Bakersfield home where they believed Arriaga was hiding and he walked out with his hands up, Kern County Sheriff Donny Youngblood told reporters.

It was not immediately clear if Arriaga, who was transported in Singh’s handcuffs from Bakersfield to Stanislaus County, had an attorney. He was expected to be formally charged next week.

FILE PHOTO: A still photo taken from surveillance video of an unidentified alleged gunman involved in the shooting death of 33-year-old police officer Ronil Singh, in Newman, California, U.S., December 26, 2018. Stanislaus County Sheriff's Department/Handout via REUTERS

Christianson said the case highlighted the dangers of a California law passed in 2017 that placed limits on how closely law enforcement can cooperate with federal agents seeking to deport illegal immigrants arrested for crimes.

Christianson had initially given Arriaga’s age as 33, but authorities later said he was 32.

Arriaga, a farm laborer who had been in the United States for a number of years after illegally crossing the border into Arizona, had prior arrests for driving under the influence, Christianson said.

“Why are we providing sanctuary for criminals, gang members?” Christianson said at the news conference. “It’s a conversation we need to have.”

California Governor Jerry Brown, a Democrat, in signing the bill into law said it provided reassurance to undocumented immigrants without sacrificing public safety. State law “fully permits the sharing of information on dangerous gang members,” Brown’s spokesman Evan Westrup said in an email on Friday.

Trump tweeted about the shooting on Thursday, days after the Dec. 22 partial shutdown of the federal government. The ongoing shutdown was triggered by Trump’s $5 billion demand, opposed by Democrats and some lawmakers in his own Republican party, for the wall.

Trump, during his campaign for president and in the White House, has denounced a number of crimes by illegal immigrants to press for stricter immigration enforcement.

Ahead of the congressional elections in November, a TV campaign ad endorsed by Trump focused on an undocumented Mexican immigrant convicted of killing two sheriff’s deputies in California.

However, multiple studies have found immigrants commit crimes at lower rates than U.S.-born Americans.

Stanislaus County law enforcement officials have highlighted Singh’s own background as a legal immigrant. The 33-year-old native of Fiji came to the United States to become a police officer, they said.

At least five people were arrested on suspicion of lying to investigators about Arriaga or helping him evade law enforcement, including some people at the Bakersfield home where he was arrested, authorities said.