The suspect was identified by police as Malik Chavis, 23, who died of a self-inflicted gunshot wound in an apartment at a Bronx housing project Thursday night, officials said.
He had 17 prior arrests, according to the law enforcement official.
Officer Diara Cruz, 24, who has two years on the job, was seriously injured after a bullet pierced her abdomen below her bulletproof vest, hitting internal organs, the law enforcement official said.
Officer Patrick Espeut, 29, also with two years on the force, was shot in the face, the official said. The bullet went through his cheek. Espeut is a staff sergeant in the Air National Guard, the official said.
Espeut was greeted with applause from fellow officers when he was released from the hospital on Friday, according to a Tweet from the NYPD.
"So far, in both cases, their condition is good," Mayor Bill de Blasio said Thursday night. "Both officers have been alert and communicating."
De Blasio called the officers brave.
"It's another example of what our officers confront every single day, keeping us safe not only on the streets of New York City, but in the stairwells and the hallways of our public housing developments," the mayor said.
NYPD tweeted that the officers' conditions were stable.
The officers were on a patrol in a housing complex in the South Bronx when they encountered two men in a stairwell, First Deputy Commissioner Benjamin Tucker told reporters.
The officers were walking with Chavis to a seventh floor apartment, where Chavis said he had his identification, according to the official.
As Chavis opened the door to the seventh floor hallway, the official said, he turned and fired at the officers.
Chavis then ran to an apartment and told a man inside, "I shot that **** cop. I ain't going back," before shooting himself, according to the official.
Giselle Cruz, who lives directly across the street, said she heard five or six gunshots.
Responding officers found the suspect dead in an apartment where a .32-caliber pistol and a shotgun were recovered.
Police interviewed other people in the building, including two men who said Chavis was trying to rob them, the official said.