EAST NEW YORK — A rookie police officer fatally shot an unarmed man late Thursday in a "pitch black" Pink Houses stairwell as his girlfriend, whom he had been visiting, watched in horror, officials and a witness said.

Officer Peter Liang, who had been working in the field since graduating the police academy in January, had his flashlight and gun out when the weapon "accidentally discharged," hitting Akai Gurley who was "a total innocent," NYPD Commissioner Bill Bratton said.

Liang, 27, and his partner were doing a top-to-bottom patrol in the stairwell of 2724 Linden Blvd., near Eldert Lane, about 11:15 p.m. when they reached an eighth-floor landing — where the lights had been out for "possibly days," Bratton said.

At the same time, 28-year-old Gurley, the father of a two-year-old, was entering the stairwell from the floor below them and started them, sources and witnesses said.

Gurley and his girlfriend, 27-year-old Melissa Butler, had tried to take the elevator but opted for the stairs when it didn't come, she said. Butler entered first and Gurley followed right behind, she said.

"As soon as he came in, the police opened the [door to the] eighth-floor staircase," Butler told DNAinfo New York.

"They didn't present themselves or nothing and shot him. They didn't identify themselves at all. They just shot."

Liang, who along with this partner had been part of an increased police presence in the Pink Houses because of high crime rates in the area, fired a single shot that hit Gurley in the chest, police said.

The officers then retreated and Liang radioed in to say that there had been an accidental shooting, sources said.

The couple then started running down the stairs after the shooting, but Gurley only made it to the fifth floor. Butler ran one floor below and asked neighbors for help, she said.

She then ran back up to her boyfriend and tried to revive him while 911 dispatchers talked her through first aid procedures until medical crews arrived, Bratton said.

"They brought him down the elevator on a stretcher. He was naked, all you saw was his boxers and a hole on the right side of his chest. It was really small. One guy was doing chest compressions, but his eyes were closed. He was gone," said neighbor Tamia Davis, 32.

Gurley was pronounced dead at Brookdale Hospital, police said.

Gurley had been dating Butler since about 2012, she said. He was at the gym earlier Thursday night and had come to visit her about 9:15 p.m., she said. Neighbors saw her braiding his hair in the hallway before he was shot.

"He was a good person. He was into making music and helping people that were struggling. He would give money if you needed it. He'd give you advice," she said.

When asked how she was coping with the loss of her boyfriend, Butler replied simply, "I'm going through it."

The Thursday-night shooting echoed a similar 2004 incident in which officers patrolling a Bedford-Stuyvesant public housing building fatally shot 19-year-old Timothy Stansbury Jr. as he tried to exit a stairwell.

The officer involved in that shooting, Richard Neri, who also had his gun draw while on patrol, said he accidentally fired after being startled by the young man on the roof of the Brooklyn project. He was not indicted.

On Thursday night, Officer Liang also had his gun drawn along with his flashlight, Bratton said.

"We leave that decision, as to whether to draw the weapon, to the discretion of the officers based on what they're encountering or what they believe they may be encountering," Bratton said.

Liang and his partner, whose identity was not immediately released, were taken to Jamaica Hospital and treated for tinnitus, NYPD officials said.

Liang, a Brooklyn resident, was placed on modified duty without his gun and badge, officials said.

Mayor Bill de Blasio called Gurley's death "a tragic accident" and joined other city leaders in calling for a comprehensive investigation.

"This is a tragedy. A life was lost," de Blasio said, adding, "There's going to be a full investigation to say the least."

"Many questions must be answered, including whether, as reported, the lights in the hallway were out for a number of days, and how this tragedy actually occurred," Brooklyn District Attorney Ken Thompson said.

The police department's internal affairs bureau is also investigating the shooting, an NYPD spokeswoman said.

The New York City Housing Authority, which maintains the Pink Houses, declined to comment because of the ongoing investigation.

Former City Councilman Charles Barron, who used to represent the neighborhood, faulted the rookie officer for the shooting and said it echoed fatal police shootings on Staten Island and in Ferguson, Mo.

"This young man should still be alive today," Barron said outside the Pink Houses Friday morning. "This is madness. It must stop. People are outraged. This is happening all over the country."

Residents of the housing project, considered one of the roughest in the city, said that the hallways are often dark, but they were fixed soon after the shooting.

"They fixed the [the lights] immediately, like after it happened," said James Esquilin, 25, who lives on the same floor as Butler. "Mr. Charles Barron was here so they came and did a couple of fixtures. It shouldn't have to take for Mr. Barron to come down for you to fix stuff. We pay rent here. We live here. We got children here."

With reporting by Danielle Tcholakian and Jeff Mays