A police officer testified emotionally in his own defense Monday about the deadly shooting of an unarmed man in a dark Brooklyn housing project stairwell in 2014.

Peter Liang got choked up and left the witness stand for about a minute to compose himself before resuming testimony at his manslaughter trial.

Liang said he was heading down a darkened stairwell with his gun drawn and his finger on the side of the weapon, as he had done many times before without a problem. "Whenever we feel unsafe, it was our discretion of when to take out your firearm," he said. "There was no set rule of when to take your weapon out."

As he opened the stairwell door, he heard a noise: "It just startled me, and the gun just went off."

He said he put his weapon back in its holster and shone his flashlight downward to see whether anyone was there. He didn't see anyone. Then he told his partner he'd accidentally fired his gun and worried he would be fired from the New York Police Department. He said he and his partner went into the hallway and argued over who would call their sergeant to report the accidental discharge.

Then, Liang said, he went back to look for the bullet, heard someone crying, went down some stairs and found Akai Gurley, with Gurley's girlfriend leaning over him.

"And I said, `Oh, my God, someone's hit!"' and radioed that a man was shot and called for an ambulance, Liang testified.

Prosecutors say Liang handled his weapon recklessly, and they have sought to use the testimony of his partner to show that the defendant, even after realizing he'd shot an innocent man, did almost nothing to help him.

Liang said he didn't initially know the address when he radioed for an ambulance, and although Gurley's girlfriend kept telling him, it took a bit for him to relay it because he was so shaken.

"I was panicking. I was shocked and in disbelief that someone was hit," he said.

He said he saw that Gurley, 28, appeared to be seriously injured, with his eyes rolled back.

"He was just laying there very still," said Liang, who choked up again but stayed on the stand.

Instead of trying CPR, Liang said, he thought the best way to help Gurley was to call for medical professionals in the ambulance.

Liang was taken to a hospital because of ringing in his ears from the gunfire. He said he also was hyperventilating and had to be given oxygen, as well as calming medication once he arrived at the hospital.

The Liang trial is being closely watched by advocates for police accountability, who see it as a counterpoint to decisions by grand juries declining to indict white police officers in the killings of unarmed black men, including those of Eric Garner on Staten Island and Michael Brown in the St. Louis suburb of Ferguson.

In this case, Liang is Chinese-American; Gurley was black.