Former NYPD officer Peter Liang was cleared of manslaughter and given probation by a Brooklyn judge Tuesday in the 2014 killing of an unarmed black man in a dark stairwell — a ruling that set off tears and denunciations from the victim’s relatives and police critics.

Supreme Court Justice Danny Chun said Liang was guilty only of criminally negligent homicide because he fired his gun carelessly but did not know Akai Gurley was in the stairwell. Chun said Liang didn’t deserve prison for a crime the rookie officer never intended during a night patrol at the Louis Pink housing project in East New York.

“He entered that night with the intention of protecting the people of the Pink Houses,” Chun said, as Liang looked on expressionless. “Shooting that gun and killing someone was probably the last thing that entered his mind. Incarceration is not necessary.”

StoryDA recommends no jail for cop who killed unarmed manStoryNYPD cop found guilty in death of unarmed manStoryPartner: Man shot by cop was 'murdered'

In ordering five years of probation and 800 hours of community service, the judge also cited expressions of remorse from Liang, 28, who left court without commenting, but earlier apologized to Gurley’s family and made a plea for leniency.

“The shot was accidental but someone was dead,” he told the judge. “ . . . My life is forever changed. I hope you give me a chance to rebuild it.”

The sentencing marked an emotional climax to a case that helped fuel nationwide protests over police use of excessive force against minorities, but also triggered an outpouring from Asian-Americans who feared Liang was being scapegoated after his February conviction.

advertisement | advertise on newsday

In tearful trial testimony, Liang said he pulled his gun because he feared for his safety in the stairwell, and then pulled the trigger by accident when he flinched at a sound. The bullet ricocheted and hit Gurley, 28, who had entered the stairwell a floor below with his girlfriend.

Chun’s ruling did not go down well among Gurley’s friends and relatives, who sobbed and shouted as the courtroom emptied. A mostly peaceful crowd of a few hundred supporters assembled outside holding signs with messages like “Jail killer cops” and “Black Lives Matter.”

“Today justice was not served to my nephew Akai Gurley,” said Hertencia Petersen, Gurley’s aunt. “Now here it is: Another black man has been murdered by the hands of a police department and the officer is not being held accountable.”

Get the Newsday Now newsletter!

The best of Newsday every day in your inbox.

Dejohn Jones, a protestor from the Bronx, said of Liang: “He took a life. For that he should have paid the price. If it was the other way around, Akai would have gotten jail time. That’s why there’s no trust.”

Gurley’s girlfriend Melissa Butler, and his domestic partner Kim Ballinger, the mother of his child, both urged Chun to impose a tough sentence in court. Afterward, Ballinger, who is suing the city, said she was “in shock” the manslaughter charge was struck, but urged calm.

“I’m against riots,” she said. “Having a riot isn’t going to overturn the verdict, it isn’t going to bring Akai back. I ask everybody, just be peaceful.”

Chun’s sentence for Liang was not unexpected, coming just weeks after Brooklyn District Attorney Ken Thompson called for probation, six months of house arrest and 500 hours of community service because the officer was reckless but didn’t intend to kill.

Thompson was not in court Tuesday. He said later the sentence was “fair under the unique circumstances of this case,” but pledged to appeal the decision reducing manslaughter to criminally negligent homicide, a lesser felony carrying up to four instead of 15 years in prison.

advertisement | advertise on newsday

“The rule of law demanded that he be held accountable,” Thompson said in a statement. “ . . . Mr Liang, who is now a convicted felon, forfeited his career as a police officer and must now always live with the fact that he recklessly caused Mr. Gurley’s death.”

Mayor Bill de Blasio urged calm.

“The death of Akai Gurley was a tragedy,” he said. “We respect the judge’s decision . . . and we ask New Yorkers to continue our city’s tradition of expressing their views peacefully.”

While the prosecution appeals Chun’s reduction of the manslaughter count, Liang lawyer Paul Shechtman said he would pursue an appeal of the remaining convictions of criminally negligent homicide and official misconduct, for Liang’s failure to help Gurley.

Asked whether Liang was “happy” to escape jail, Shechtman shook his head.

advertisement | advertise on newsday

“I think he’s very sad about the whole thing,” Shechtman said. “The word happy and Peter Liang have not appeared in the same sentence in 18 months.”

With Matthew Chayes, Maria Alvarez and Alison Fox