Other officers fired at the suspect, killing him, according to Police Commissioner James O'Neill.
The officer, identified as 34-year-old Christopher Wintermute, was treated at St. Luke's Hospital and was released around 7 a.m. to the cheers of fellow officers.
He saluted and was helped into a police van to be taken home with his family.
RAW VIDEO: Officer released from the hospital
O'Neill said at a hospital briefing that eight uniformed officers responded to a resident's 911 call shortly before 2 a.m. about a neighbor, later identified as 29-year-old Victor Hernandez, at the building on Frederick Douglas Boulevard who was harassing her, banging on doors and breaking glass.
Sharon Allen said her sister was forced to call the police about Hernandez, the building's superintendent.
"She said that the man is dead in front of my door," Allen said. "She's the one who called because he was acting a little off the rocker. He was acting crazy."
When officers arrived, they began a search for the suspect. Wintermute, a 7-year veteran of the force, suddenly came upon Hernandez, who was standing in the hallway naked and holding a semiautomatic 9mm handgun, according to police.
"The officer yelled for help as the struggle continued, and the other officers discharged their firearms, striking the suspect several times," O'Neill said. "Our officer had been shot one time in the chest. The round did not penetrate his bullet-resistant vest. Our officer had also been punched numerous times, resulting in injuries to his face."
O'Neill said bodycam video showed the suspect and the officer fall to the ground.
"It's extremely disturbing," O'Neill said of the video.
WATCH: NYPD, mayor update the investigation
Fellow officers ran to assist and fired several rounds at Hernandez, who was killed. The handgun was recovered in the hallway.
"The 29-year-old suspect, who has had previous interactions with the police, was pronounced deceased at Harlem Hospital," O'Neill said. "The suspect's firearm was recovered at the scene."
Officer Wintermute was rushed to St. Luke's Hospital in Morningside Heights, where he was treated for non-life threatening injuries.
"Thankfully we can report that his vest saved his life," Mayor Bill de Blasio said. "I visited with him this morning and he's in good spirits. He's a seven-year veteran and an example of courage and strength."
Police said Hernandez's run-ins with the law were domestic violence incidents. A building resident said he recently became the super.
"He's been with us a couple of months," Octavia Harrison said. "I know he had children and a young lady that was there with him all the time, fairly quiet guy in the building."
His mother is a retired NYPD officer.
Police say the incident underscores the dangers officers face every day.
"Those seconds and minutes seem like hours, and he stayed in there and did what he had to do," PBA President Pat Lynch said. "He was struggling and fighting for his life and your life."
This is the fourth police-involved shooting in just eight days in the city, but it's the first of those where an officer was shot.
* More Manhattan news
* Send us a news tip
* Download the abc7NY app for breaking news alerts
* Follow us on YouTube