A Manhattan judge on Tuesday lashed into a Harlem man convicted of attempted murder — telling him that “black lives don’t matter to black people with guns” before tossing him in prison for 24 to 26 years.

“Black lives matter,” Justice Edward McLaughlin told defendant Tareek Arnold, 24, as he sentenced him in Manhattan Supreme Court.

“I have heard it, I know it, but the sad fact is in this courtroom, so often what happens is manifestations of the fact that black lives don’t matter to black people with guns.”

Arnold, who is black, shot rival Jamal McCaskill, also black, four times at close range in the summer of 2015. He also has a prior gun possession conviction.

Prosecutor Meghan Hast asked for the maximum, arguing that “but for extreme luck, this would have been a homicide.”

Bizarrely, McCaskill, 39, testified for the defense and insisted that Arnold wasn’t the culprit even though the Harlem shooting was caught on surveillance video.

That spurred McLaughlin to also lash into the victim, who was in court Tuesday sitting with Arnold’s family.

“The video shows that Mr. McCaskill is an abject liar,” said the judge, who has presided over hundreds of gun cases and often rails against the city’s endemic gang violence.

After cops nabbed Arnold for the shooting, he escaped with his hands cuffed behind his back, using his shoulder to shove an officer to the ground. He was on the lam for almost a month. The jury also convicted him of escape, gun possession and assault.

Defense lawyer Mark Jankowitz requested the minimum sentence of 10 years, arguing that Arnold’s 1-year-old son would be without a father.

McLaughlin demurred: “Do not ask a judge in this room, in this building, or in this system to somehow make amends for the people who commit violent acts and who by their violent acts wind up leaving people orphaned, abandoned, fatherless, etc.”

The judge then handed down the stiff sentence.