LANCASTER, Calif. (AP) – Los Angeles County sheriff’s officials say two undercover deputies shot and wounded a masked man who allegedly tried to rob them using a BB gun in Lancaster.

Lt. Victor Lewandowski says the deputies were in an unmarked car when the suspect knocked on the front driver-side window with the gun Tuesday evening.

Lewandowski says the deputies, fearing for their lives shot the suspect through the window.

The man managed to run about a block before collapsing. He was then taken to a hospital for surgery. His condition wasn’t immediately known early Wednesday and his name wasn’t released.

Investigators believe the man intended to rob the deputies.

The deputies were not hurt.