Investigators say 36-year-old Nelson Vergara was shot twice by Joseph Baez, who was allegedly shooting at a 17-year-old near the officer on the street in University Heights.
Vergara was able to shoot Baez, who was arrested at the hospital, before radioing for help.
Police say Vergara had just finished his shift and was returning home when a group of men started heckling him.
NYPD Commissioner Ray Kelly says one even threw a bottle at Vergara, who quickly identified himself as a police officer.
"As he approached the group, a green Honda pulled up to the scene," Kelly said. "A male...exited the vehicle and began firing several times at a man in that group."
Caught in the middle of the crossfire, Vergara was shot in the shoulder and leg. Amazingly, he was still able to squeeze off 11 shots and handcuff the bottle thrower.
Vergara is a 12-year veteran of the department, and a Marine who has served two tours in Iraq. He and his wife have two children.
WAKE UP WITH EYEWITNESS NEWS! Click here to download the WABC Eyewitness News Alarm Clock app from iTunes. or search WABC or 7online in the app store.
Get Eyewitness News Delivered