Updated

A New York City police officer shot and killed a man who pulled a knife on him Thursday after the officer was slashed in the neck while trying to stop the man from assaulting an elderly woman, authorities said.

Officer Filippo Gugliara, 24, was hospitalized in stable condition. Mayor Bill de Blasio and Police Commissioner William Bratton praised his response at a press conference.

"He faced quite clearly a life-threatening situation with this individual," Bratton said. "But for his intercession, the assault on this 78-year-old woman - we don't know what would have happened."

The incident unfolded at about 2:15 p.m. near a subway station in the Coney Island section of Brooklyn. The 58-year-old suspect was involved in a dispute in a shop that spilled out into the street, they said.

The suspect turned and pushed an elderly woman as she intervened in the incident, police said. The officer, who was patrolling an elevated subway station, heard the commotion and came down the street to help the woman.

The man pulled a knife and slashed the officer, police said. The officer responded by firing two rounds, hitting the man in the torso.

The knife was recovered at the scene.

Doctors said the officer only needed a few stitches. They also said they believe the shoulder strap of the officer's vest apparently deflected the knife, preventing the wound from being more serious.

"Thank God this officer came out OK," De Blasio said.

The assault victim was treated for minor injuries. Police said she had no previous connection to the suspect.

The Associated Press contributed to this report