The San Luis Obispo County Sheriff’s Office identified the wounded deputy as 28-year-old Nicholas Dreyfus of the Paso Robles Police Department.
The sheriff’s office said Dreyfus has been with the department since October 2018 and is currently assigned to its North County Sheriff’s Station in Templeton.
Hundreds of California police officers in and around Paso Robles were hunting Thursday for 26-year-old Mason James Lira, the suspected gunman who shot Dreyfus and a transient man in the back of the head.
The shooting unfolding around 4 a.m. Wednesday, when Lira fired at police cars as they entered downtown Paso Robles, authorities said.
Two sheriff's deputies heard gunshots but didn’t see the attacker until they were outside of their patrol car when shots were fired at them. Dreyfus was hit in the head. His partner returned fire and dragged the deputy to cover behind a police car.
“We feel that this was an ambush, that he planned it, that he intended for officers to come out of the police department and to assault them,” San Luis Obispo County Sheriff Ian Parkinson said.
While officers searched for Lira, they received a report of a body near the train station and they found the body of a 58-year-old man on the tracks.
He appeared to be a transient who was camping out overnight, Paso Robles Police Chief Ty Lewis said. It wasn’t immediately clear whether he was shot before or after the attack on the police station.
Dreyfus was transported to an area hospital before being taken to a trauma center to undergo surgery, the sheriff’s office said.
"He is listed in guarded condition and his prognosis is good," a sheriff's statement said Thursday, adding that the deputy's wife and family were with him.
"It's a wide-ranging, full-on, full-scale effort," said Tony Cipolla, spokesman for the San Luis Obispo County sheriff. "We're right behind him. You can't run forever."
Police closed parts of a freeway and used flash-bangs during a search of apartments.
Authorities have not determined the motive for the attack. But Lira, a transient from the Monterey area, was arrested previously for making terrorist threats, said Cipolla, who could not immediately provide more information about that case.
The attacks came just five days after another unlikely California crime location, when the community of Ben Lomond in Santa Cruz County farther north was the scene of an ambush on police.
Santa Cruz Sheriff's Sgt. Damon Gutzwiller, 38, was killed and another deputy was injured Saturday in an attack allegedly carried out by an Air Force sergeant armed with homemade bombs, an AR-15 rifle and other weapons. Santa Cruz County Sheriff Jim Hart said the suspect, Steven Carrillo, was intent on killing officers.
Carrillo, 32, was arrested and the FBI is investigating whether he has links to the killing of a federal security officer outside the U.S. courthouse in Oakland during a protest against police brutality on May 29. A white van was spotted at both attacks and the FBI is seeking the public's help to find it.
Parkinson said were no events in the Paso Robles area of imminent arrests by authorities that could have triggered the violence. He also said investigators didn't know if the attack was connected to anger swelling nationwide at law enforcement after the death of George Floyd in Minneapolis police custody.
"You see what's happening nationally, you see the riots, you see the looting, you see the acts of violence occurring... there's naturally fear as a result of that," he said. "So trying to calm the community has been our goal."
The Associated Press contributed to this report.