MERCED, Calif. (KFSN) -- Two suspects are now in custody for the shooting near Livingston Wednesday.
Investigators say it started with a violent home invasion robbery.
However, it ended with a sheriff's deputy being shot in his bulletproof vest.
Deputies removed more than five thousand marijuana plants from an illegal indoor grow at this home east of Livingston Wednesday.
Investigators say that's what these two men were after when they showed up at the property.
"That evening individuals kicked in the door at a house, and they were there specifically to get their hands on that marijuana," Said Sheriff Vern Warnke.
Sheriff Warnke says the suspects beat up one man at the home and then opened fire on Deputy Oscar Ochoa when he responded to a disturbance call.
"Within 1 minute of him being on the scene, he was ambushed and started to receive shots, and it wasn't until the 3rd shot was fired at the deputy that he was able to determine where shots were coming from and return fire, thus stopping the incoming rounds," said Warnke.
A CHP helicopter crew joined the search for the suspects and spotted 27-year-old Javier Delgadillo-Munoz hiding in a tree with the help of an infrared camera.
Deputies quickly arrested him and later tracked down 35-year-old Paul DeMarcus Glenn, who is now facing charges for the attempted murder of a peace officer.
"I'm very fortunate that the deputy who was shot suffered minor injuries, and because of his training and quick response at the time he was receiving those shots it prevented him from getting severely injured or killed," said Warnke.
Sheriff Warnke spent much of this news conference sharing his anger over state laws that have reduced some felonies to misdemeanors and legalized the recreational use of marijuana.
He also called the media back to his office after learning that Delgadillo-Munoz is in the country illegally and has a criminal history.
Warnke has been an outspoken critic of California's sanctuary law since one of his sergeants was shot back in September by an undocumented immigrant with past arrests for domestic violence.
"I want everyone out here to know that this is not going to be tolerated in this county. If they're going to commit crimes like this and my deputies are getting shot at, when we're done with him he's going back to his country of origin," said Warnke.