A California man who ambushed and shot a police deputy and killed a homeless was killed following a massive manhunt on Thursday afternoon. The search involved Paso Robles police and San Luis Obispo County Sheriff's deputies, as well as law enforcement officers from neighboring cities, the California Highway Patrol and the FBI. Four officers sustained non-life-threatening injuries in the shooting spree over two days, NBC News reported.

On Wednesday, Mason James Lira (26) opened fire at the Paso Robles police station. When officers responded, he shot a San Luis Obispo County deputy in the side of his head. He is also accused of killing a 58-year-old homeless man.

Mason James Lira
Mason James Lira Twitter/SLO County Sheriff

To track down Lira, officers locked down a 2-mile (3-km) radius on the southern end of Paso Robles near the Salinas River on Thursday afternoon at around 2:10 pm. An officer was shot at, as they were searching the riverbed. The injured officer was swiftly taken to a hospital. More officers arrived at the scene to search for Lira as he opened fire on them, injuring two other officers, CBS News reported.

Upon searching along the Salinas River, they found Lira hiding in the riverbed. As he tried to flee, he was shot at and died on the scene. Officers recovered two handguns which are believed to be stolen from a commercial burglary in San Luis Obispo just a few days earlier.

The Paso Robles Police and the San Luis Obispo (SLO) County Sherrif's Office took to Twitter to inform that the suspect was taken down. The SLO County Sheriff further noted that there was only one suspect. The wounded officers are employed at the California Highway Patrol, Arroyo Grande Police Department and Kings County Sheriff's Office. They were transported to a local hospital and are in stable condition with non-life-threatening injuries.

The deputy wounded in Wednesday's ambush has been identified as the 28-year old Nicholas Dreyfus. "All of the Sheriff's Office has him, his wife, and his friends and family in our thoughts at this time", the SLO County sheriff's office said in a statement.

Lira suffered several mental illnesses and refused to take his medication, his father told the Associated Press. He said his son was suffering from schizophrenia, Asperger's syndrome and attention deficit hyperactivity disorder. He lived in his fantasy world and often thought that he was a special agent or a soldier. He said Wednesday's ambush might have been a suicide attempt and that he did not have a beef with the police.