Well, Jimmy O’Neill gets to keep his badge. Pity it means more to him than the integrity of the New York Police Department he leads, in a manner of speaking.

The commissioner dropped the hammer on scapegoat-cop Daniel Pantaleo Monday, bringing an ostensible end to the city’s five-year-long Eric Garner ordeal.

But it would be a mistake to think of the affair as concluded. In many important respects, it has just begun.

First, and briefly, some detail:

On July 14, 2014, the last day of his life, Eric Garner of Staten ­Island undertook to become a cop-fighter. That’s a risky enterprise for anyone — as it must be, because to resist arrest is to challenge fundamentally the authority of a city to keep its streets safe, and such confrontations are only going to end one way: with order restored.

For Eric Garner — a severely asthmatic diabetic with a failing heart — the day ended in the medical examiner’s office, a personal tragedy but hardly anyone’s fault other than his own. And this ­remains true even though much of New York’s political establishment has been declaiming otherwise ever since.

Garner’s supporters and the liberal establishment accuse Pantaleo of killing Garner with an illegal chokehold. But that has never been clear, and anyway, the US Justice Department declared precisely the opposite last month, ­after long and detailed study of the facts.

The only certainty in this case is ambiguity — and custom, case law and common sense in New York have long dictated that in such a circumstance, the benefit of the doubt goes to the officer. Try to imagine the chaos that would ensue if that principle were turned on its head.

But instead Pantaleo’s own head rolled. Why?

Because the mayor of New York City is a foolish man.

And because his police commissioner is a careerist to whom the fates offered an opportunity to demonstrate wisdom, judgment and exquisite courage — and who decided he liked his badge better.

His call. Pantaleo’s loss. But also New York City’s.

It is easy to misunderstand the stakes in this endless melodrama. So let’s be clear: Commissioner O’Neill’s principal duty isn’t to the officers of the NYPD. It is to the city itself and its nearly 9 million residents.

But part of a leader’s responsibility, when Garner-like tensions arise, is to make it as clear as possible that street conflict is between cops and specific lawbreakers — and not between cops and the larger community.

Too many of the city’s leaders — Bill de Blasio is at the top of this list — embrace an opposite ­assumption: that the police have targeted the community, not the lawbreakers, and are therefore the enemy.

It’s a dangerous, pernicious notion, and it has led directly to the abandonment of proven, humane police practices; to chaotic streets and subways; to those water-bucket humiliations of patrol ­officers — and to Sunday’s housing-project attacks on cops in Brooklyn.

This animating philosophy was embraced long ago in Chicago, where they have mass shootings every summer weekend — just without the scary rifles.

Also in Philadelphia, where they hold rallies for accused cop-shooters.

Ditto in Baltimore, where . . . well, Baltimore defies description, so let’s just leave it at that.

New York is almost a sea of tranquility measured against those cities. But it wasn’t always so, and now the question is what happens next?

De Blasio doesn’t care. He’s clearly in the other camp.

And now it seems that O’Neill is, too, at least to this extent: When he had an opportunity to do the right thing for an innocent ­officer caught up in an impossible circumstance, he didn’t.

He blinked.

And the message to the NYPD’s 34,000 officers is clear enough: Comes the crunch, you can’t count on your bosses.

It’s a prescription for evasion, avoidance and dereliction. Daniel Pantaleo takes the hit, but New York City is the loser.

Bob McManus is a contributing editor of City Journal.