Police and sheriff's deputies in Central California are searching for a man they say shot a deputy in the head early Wednesday and killed another man in what investigators described as an "ambush" attack on a police station.

The San Luis Obispo Sheriff’s Office said Mason James Lira, 26, opened fire at the Paso Robles Police Department before 4 a.m. Wednesday, shooting a responding deputy in the head.

The deputy's partner dragged him to safety and returned fire, San Luis Obispo County Sheriff Ian Parkinson said.

The bullet remained lodged in the deputy's head and he's in serious condition at the hospital, Parkinson said.

"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," he said.

CALIFORNIA DEPUTY SHOT IN HEAD IN 'AMBUSH' ATTACK, INVESIGATORS SAY 

The sheriff’s office said Lira also killed a man who was found shot to death near railroad tracks a few blocks from the police station.

The department said in a press release it conducted a widespread search through downtown Paso Robles but Lira remains at large.

Around 11 p.m. police were seen barricading areas of downtown Paso Robles near Spring Street while searching with helicopters, according to a FOX 11 San Luis Obispo reporter.

Lira, described as a transient from Monterey, should be considered armed and dangerous, the department said.

CLICK HERE TO GET THE FOX NEWS APP

In a press conference Wednesday Parkinson said the “unprovoked attack on law enforcement” by a suspect “laying in ambush” at the station was an “act of a coward.”

Paso Robles is a small city along California's central coast, about 175 miles northwest of Los Angeles.

Fox News' Bradford Betz contributed to this report.