The incident began at 4:24 p.m. when a 911 caller reported that someone was firing a gun at the corner of Wadsworth Avenue and 187th Street, the police commissioner, James P. O’Neill, said during a news conference at the Mount Sinai St. Luke’s Hospital.

Moments later, two plainclothes officers from the 34th Precinct arrived in an unmarked car and spotted Mr. Leizado with a gun fleeing down 187th Street toward Broadway, Mr. O’Neill said.

Officer Vartanian got out of the car and chased the gunman on foot as he ran around the corner and into a parking lot on Broadway. The fleeing man hid behind a car at the back of the lot and fired three rounds, hitting the officer under his right arm. The wounded officer managed to fire back once.

“The amount of courage this police officer showed is quite unbelievable,” Mr. O’Neill said.

Then, the second officer, who has not been identified, barreled into the parking lot in the unmarked police car, jumped out and started firing from behind the driver’s side door, the commissioner said. He squeezed off three shots at the gunman. One of the gunman’s bullets went through the windshield of the police car where the driver sits.

“This was a fast, intense episode,” Mayor Bill de Blasio said. “We saw, from the video we observed, a very, very dangerous situation unfold.”