Moments after his gun went off in a dark Brooklyn housing project stairwell, Officer Peter Liang voiced fear that he was going to lose his job, his partner from that night testified Tuesday.

The two shaken rookie cops spent the next several minutes trying to figure out how to report what happened to their sergeant, Officer Shaun Landau testified. Landau indicated he didn’t know right away that Akai Gurley — struck by the bullet — was dying on the stairs below.

The officers were on patrol on Nov. 20, 2014, in the Pink Houses in East New York when they rode the elevator to the eighth floor the night Gurley, 28, was shot. Gun and flashlight out, Liang pushed open a door to the stairwell with his shoulder and almost immediately came running back out, Landau said.

“I hear a shot go off. I heard footsteps, sounded like running,” said Landau. “I was in shock, the gun just fired out of nowhere. He said it went off by accident. He said ‘I’m fired.’”

Landau was a prosecution witness in the trial of Liang, 28, who is charged with second-degree assault, criminally negligent homicide, reckless endangerment, and official misconduct. He has pleaded not guilty and if convicted faces a maximum sentence of 5 to 15 years in prison.

After hearing the shot, Landau said he assured Liang it would be all right and they just had to report the accidental discharge of the gun, seemingly unaware Gurley had been struck while standing on the seventh-floor landing below.

Landau said the officers then spent the next four minutes going back and forth over who would call the sergeant and decompressing from “the initial shock of everything.”

“He just looked upset,” Landau, also 28,, said about Liang. “He was just standing there.”

But when Landau went into the stairwell to check out what he thought was a bullet mark on the wall, he quickly realized something worse happened.

“It sounded like a person. It sounded like grunting, crying,” he said. “We ran down the stairs. It was pitch black.”

They went all the way down to the fifth-floor landing, where Landau testified he saw Gurley lying on his back, a woman hunched over him. In a harrowing description earlier on Tuesday, Gurley’s girlfriend, Melissa Butler, testified she watched him bleeding out during his final moments.

“I leaned over him in a puddle of blood and urine. I was telling him to stay with me, I’m getting help,” she said, breaking down in tears.

Landau said he watched Liang bend down next to Gurley, but didn’t see Liang take over the CPR. “He just yelled out, ‘oh my God. Someone’s shot,’” Landau recalled.

He said Liang then called out on the radio, but testified that he didn’t say on the transmission that someone had been shot. Landau said he then went into the hallway to wait for help.

Later, when a supervisor finally took Liang’s gun, Landau said his partner broke down.

“Officer Liang then fell to the floor and started crying,” he said.

Under cross-examination, Liang’s attorney Robert Brown said Landau told police the day after the shooting, and again five days later, Liang had in fact reported there was an accidental discharge of a weapon and that someone had been shot.

There was no record of that radio transmission, a law enforcement official said outside of court. Landau has been placed on modified duty and is facing departmental charges for not taking quicker action to help Gurley after the shooting. He is also being sued by Gurley’s family.