It was close to 4 a.m. on Thursday when Officer Brian J. Groves swung open a stairwell door in a building on the Lower East Side and saw a man with a pistol, the police said.

As the officer called to his partner, the man fled down the stairs, stopped after a few flights and fired a shot that hit Officer Groves, who was in pursuit just a few feet away. The officer fired back before realizing he had been hit.

Officer Groves was struck near the heart, but the impact was blunted by a bullet-resistant vest. The officer later collapsed from the pain the bullet’s force had caused, but doctors said he was expected to recover.