A man arrested and accused of shooting a California police officer was previously in jail and was not even supposed to be in the country.

The California Highway Patrol arrested 51-year-old Guadalupe Lopez-Herrera of Dos Palos on Thursday after a 20-hour manhunt and a nearly hour-long high-speed chase.

(Video: KFSN)

Lopez-Herrera is in the U.S. illegally, according to Merced County Sheriff Vern Warnke, and was in custody earlier this year on charges of domestic violence. He reportedly had threatened the lives of his wife’s family.

#BREAKING Captured! This is the suspect accused of shooting a Merced County detective yesterday. He was just arrested on I-5 near Kettleman City following a pursuit from Paso Robles. @ABC30 pic.twitter.com/nUc9UTrNAZ — Sara Sandrik ABC30 (@SaraABC30) September 5, 2019

“This person is not a legal citizen within the United States. We had him in our custody in January of this year. And because of the folks in Sacramento limiting our ability to cooperate with ICE, we could not turn him over,” Warnke said at a press conference on Thursday.

Police were following up Wednesday on a domestic violence report from the weekend, intending to arrest the suspect for violating a restraining order.

“We had word he was hiding in this residence. It was on Sunday when this domestic violence occurred, deputies went out to investigate. In moments, shots were fired,” Merced County Sheriff’s Officer deputy Daryl Allen told KFSN-TV.

Lopez-Herrera opened fire on deputies Wednesday at a home in Dos Palos, which is about 60 miles northwest of Fresno. One officer was shot in the bulletproof vest and then in the leg, according to Warnke who said the wounded sergeant joined the pursuit after Lopez-Herrera fled the scene. He was later taken to a hospital with non-life-threatening injuries.

(Video: Merced Sun-Star)

The suspect reportedly hijacked another vehicle as police continued the manhunt on the ground and in the air, eventually leading to another pursuit through several Central Valley counties Thursday morning before Lopez-Herrera was apprehended after officers used a spike strip on Interstate 5 in Fresno County to disable the truck.

BLUE ALERT – STATEWIDE@MercedSheriff IF SEEN, CALL 9-1-1 pic.twitter.com/WkxDlOC5qE — CHP – Alerts (@CHPAlerts) September 5, 2019

Although Lopez-Herrera was in custody earlier this year for a domestic violence charge, he was released thanks to California’s SB 54, the 2017 California Senate Bill 54 signed by former Gov. Jerry Brown which prevents local law enforcement agencies from cooperating with or providing information to Immigration and Customs Enforcement about arrests of illegal immigrants.

Current Democrat Gov. Gavin Newsom has upheld the state’s so-called sanctuary status, declaring in his inaugural speech in January that California would be a “sanctuary to all who seek it.” In July, Newsom signed a budget bill that extended public health insurance to low-income immigrants who are in the country illegally and he has repeatedly tied the hands of local law enforcement.

California Gov Newsom limits use of lethal force by police with new law https://t.co/ADjtYq4ftK — Conservative News (@BIZPACReview) August 20, 2019

Lopez-Herrera’s criminal history includes assault with a deadly weapon, felony assault, spousal abuse, possessing narcotics, and violating his probation, according to Warnke who admitted his frustrations with California’s policies on Thursday.

“Bottom line is our immigration policies need to be revamped because we’re gonna continue to have more of this situation happen,” he said. “We knew ahead of time this guy’s potential for violence was there.”