A masked man who allegedly tried to rob a pair of undercover sheriff’s deputies Tuesday in Lancaster by pointing a BB gun at them was shot and wounded, but survived.

The deputy-involved shooting took place near the intersection of Kingtree Avenue and Avenue H4 at about 5:45 p.m., according to Sheriff’s Lt. Victor Lewandowski. The suspect was wearing a mask, knocked on the car window with the BB gun causing the deputies to fire from inside the car.

The suspect managed to run about one block before collapsing. He was then transported to a local hospital where he underwent surgery. Deputies set up a perimeter around the scene and initiated a search for any accomplices.

Neither the suspect’s name nor condition was known at press time.