Two city police officers are recovering after they were shot Thursday night at the Melrose Houses in the Bronx.

Authorities say 29-year-old Patrick Espeut and 24-year-old Diara Cruz are in stable condition.

Police say the man who shot them later killed himself.

The NYPD says the officers were patrolling a building on East 156th Street around 8 p.m. when they came across two men in the stairwell.

They asked one of the men for ID. The man said he was going to go upstairs and get ID, turned around, and then fired on the officers, according to police.

The gun is seen to the left of 23-year-old Malik Chavis's photo in this story.

Police sources identify Chavis as the shooter. Officer Espeut was shot in the face and Officer Cruz was shot in the stomach.

"This shows the danger. You never know what you're going to encounter on those stairwells," said Pat Lynch, the president of the NYC Patrolmen's Benevolent Association.

The officers were transported to Lincoln Hospital. Officer Espeut was released Friday afternoon.

He was initially brought out in a wheelchair, but he then stood up, waived to applause, and told everyone that he was doing OK.

The officer was quite fortunate, as the bullet went through his nose and then through his cheek. He had only a very small bandage on his nose Friday.

A third officer who was with Espeut and Cruz on patrol was not hurt.

They were all assigned to the PSA7 housing division.

Investigators say Chavis then ran into an apartment, where police eventually found him dead of an apparent self-inflicted gunshot wound.

The person who was with Chavis was taken into custody, and several others were taken in for questioning.

"We did recover a 32 caliber gun inside the apartment while rendering aid to the perpetrator. We also recovered a shotgun in that apartment as well," said NYPD Chief Robert Boyce.

The shotgun that police say was found in the apartment is seen below the photo of the gun in this story.

"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 in the hallways of our public housing developments," said Mayor Bill de Blasio.

Both of the wounded officers have been on the force for two years.

The shooting comes as there is a major trial going on in Brooklyn, the manslaughter trial of housing officer Peter Liang.

During testimony Friday, the prosecution and defense argued over whether they could bring up the Bronx shooting. The judge said they could not bring it up.

That case will resume on Monday. Officer Liang is expected to testify about the shooting of Akai Gurley.