As expected, Police Commissioner James O’Neill fired Officer Daniel Pantaleo on Monday for his role in the 2014 death of Eric Garner. It was what Mayor Bill de Blasio wanted; it was what the mob wanted.

Whether it was fair — or wise — is another matter.

We didn’t think O’Neill had sufficient cause to dismiss Pantaleo. A grand jury declined to indict him, and the Justice Department found no grounds for charges.

Pantaleo was caught in a no-win situation: Police were responding to calls of illegal cigarettes being sold outside local stores. Garner had been nabbed for doing that several times before.

This time, Garner decided to resist arrest, leaving police no choice but to use force.

The fact that Garner was 350 pounds and suffering from underlying health issues and that EMTs failed to administer proper treatment all contributed to his death. It was a tragedy, but not a tragedy caused by malice.

O’Neill’s decision makes it harder for the hardworking NYPD cops on the street. They believe, understandably, that the city won’t stand behind them when a situation goes south. After O’Neill’s decision, police union president Patrick Lynch called the department “rudderless and frozen. The leadership has . . . left our police officers on the street alone.”

Nor is it likely the cop-haters will be satisfied or that disrespect for the police — egged on for years by cynical pols like Mayor de Blasio — will now quickly fade.

Just this past weekend, thugs attacked cops at a Brooklyn housing project. People threw objects at the officers (a growing trend, it seems), and gunfire broke out.

Though no one was hit by bullets, three cops were injured in the melee. And that follows a rash of attacks on cops with buckets of water.

Not long after Garner’s death, a madman fatally shot two officers, Wenjin Liu and Raphael Ramos. The recent attacks haven’t been as horrific, but unless the city’s leadership — the mayor, the City Council — stops encouraging hatred toward the police, the city is risking more tragedy.

It’s also flirting with an upsurge of crime. In a tweet, Lynch’s union asked: “How are cops supposed to do our job in this environment?” With Pantaleo’s dismissal, that’s a question politicians must ask.

The city now has an opportunity to heal — and to get past the anti-cop hatred that has made policing difficult.