“Even as we’re attempting to find balance,” Mr. Bratton said, “it’s unfortunate that there are people in our city and our society that, despite our best efforts, that are going to be criminals and many of them are violent criminals and we need to separate them from the rest of us. And this individual I think is one of those.”

The killing again plunged the Police Department into mourning. Ten months to the day, on Dec. 20, two uniformed police officers — Wenjian Liu, 32, and Rafael Ramos, 40 — were ambushed in Brooklyn. The suspect in that shooting, Ismaaiyl Brinsley, committed suicide in a subway station. Officer Brian Moore, 25, died in May, two days after he was shot by a gunman who fired into his patrol car. The suspect, Demetrius Blackwell, 35, has been charged with first-degree murder, attempted first-degree murder and other crimes. He has pleaded not guilty.

Image Officer Randolph Holder Credit... New York Police Department

In an interview after Officer Holder’s shooting, Justice McLaughlin noted that Mr. Howard had never been convicted of a violent crime as an adult, though court records show that the judge was aware of a sealed juvenile conviction for robbery, and that the prison sentences he had served for drug possession and sale had done nothing to keep him from breaking the law over and over.

Justice McLaughlin said he also took into account a social worker’s report, submitted by the defense, that said Mr. Howard was a child of addicts who had been hooked on PCP since he was a teenager. The report said that Mr. Howard’s arrests had all stemmed from his addiction and that he would benefit from treatment.

“When I get out, I go back to PCP and I know I have to break that cycle,” Mr. Howard told a social worker, according to the report. He was working in construction in Rye, N.Y., at the time of his October 2014 arrest.

Justice McLaughlin said he also received a long letter from the mother of Mr. Howard’s child, who begged for leniency. “When you get a robe, you don’t get a crystal ball,” the judge said, adding that he had considered the national conversation around drug sentencing. “Diversion is a good thing. It has a lot of support.”