A rookie police officer who shot an unarmed man dead in a darkened public housing stairwell was convicted Thursday of manslaughter in a case closely watched by advocates for police accountability.

The courtroom audience gasped and Officer Peter Liang, who had broken into tears as he testified about the 2014 shooting of Akai Gurley, buried his head in his hands as the verdict came after 17 hours of jury deliberations. Liang is the first New York City police officer convicted in an on-duty death since 2005.

The manslaughter charge, a felony, carries up to 15 years in prison, though no requirement for any prison time. Liang was dismissed from the NYPD right after the verdict. His sentencing is April 14.

UPDATE: Partner of Cop Convicted in Stairwell Shooting Fired by NYPD

But an uncertainty remains: Brooklyn state Supreme Court Justice Danny Chun has yet to rule on Liang's lawyers' request to dismiss the charges. Liang also was convicted of official misconduct, a misdemeanor.

Brooklyn District Attorney Kenneth Thompson said "justice was done" for Gurley.

"He was an innocent man who was killed by a police officer who violated his training," said Thompson, whose mother was a police officer.

But Liang's lawyers said they struggled to understand how the jury could find him guilty in a shooting he said happened accidentally in a pitch-dark stairway.

"If that's not a time to pull out your gun, I don't know when is," said defense lawyer Robert Brown. He said Liang would appeal.

Liang, who remains free on bail, left the courthouse without comment.

The shooting happened in a year of debate nationwide about police killings of black men. Activists have looked to Liang's trial as a counterweight to cases in which grand juries have declined to indict officers, including the cases of Michael Brown in Missouri and Eric Garner in New York. Like Gurley, Brown and Garner were black and unarmed. Liang is Chinese-American.

Thompson cautioned that Liang's case shouldn't be commingled with others. But relatives of other New Yorkers killed in police encounters had joined Gurley's family outside court during the trial to call for police accountability.

"I just want to say thank you, thank you, thank you to everyone," Gurley's mother, Sylvia Palmer, said after the officer's conviction.

Meanwhile, Liang's supporters have said he was scapegoated for past injustices.

And the head of Liang's union, Patrolmen's Benevolent Association President Patrick Lynch, said the verdict "will have a chilling effect on police officers across the city because it criminalizes a tragic accident."

Lynch wasn't in court for the verdict. While New York police officers often fill rows of courtroom seats when one of their own faces charges, few officers appeared during Liang's trial.

Mayor Bill de Blasio, a Democrat, said he respected the jury's decision and hoped it would bring Gurley's family some sense of finality.

The last officer convicted in a killing in the line of duty was Brian Conroy. He was found guilty in 2005 of criminally negligent homicide in the shooting of Ousmane Zongo, an African immigrant, during a police raid. Conroy was sentenced to probation and 500 hours of community service.

Liang was patrolling a public housing high-rise with his gun drawn when he fired. The bullet ricocheted off a wall and hit the 28-year-old Gurley on a lower floor.

Liang, 28, said he had been holding his weapon safely, with his finger on the side and not the trigger, when a sudden sound jarred him and his body tensed.

"I just turned, and the gun went off," he testified.

Prosecutors said Liang handled his gun recklessly, must have realized from the noise that someone was nearby and did almost nothing to help Gurley.

Liang said he initially looked with his flashlight, saw no one and didn't immediately report the shot, instead quarreling with his partner about who would call their sergeant. Liang thought he might get fired.

But then, he said, he went to look for the bullet, heard cries and found the wounded Gurley and his distraught girlfriend.

Liang then radioed for an ambulance, but he acknowledged not helping Gurley's girlfriend try to revive him. Liang explained he thought it was wiser to wait for professional medical aid.

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

Liang's partner, who was not charged criminally and testified in the case, faces internal disciplinary proceedings.

While Liang's trial unfolded, city Officers Patrick Espeut and Diara Cruz were shot and wounded during a similar stairwell patrol in a different public housing complex. The gunman later killed himself.