Mayor de Blasio’s efforts to have it both ways on policing just bit him where it hurts: Federal Judge Charles Haight has tossed a proposed settlement of two lawsuits involving the NYPD’s counterterrorism intelligence-gathering.

This, when the plaintiffs pronounced themselves fully satisfied with the deal.

Haight based his ruling almost entirely on a discredited report by NYPD Inspector General Philip Eure — whom de Blasio appointed as a sop to the cop-bashers.

The judge demands stronger civilian oversight of future investigations — and a stronger role for himself, with those civilians filing confidential reports with the court.

He also accused the NYPD of a “systemic inclination” to ignore court orders stretching back decades — a charge utterly without foundation.

As we’ve said for years, the now-abandoned “Muslim mapping” program was a critical information-gathering tool to aid in counterterror operations. It certainly was not, as media reports had it, a wholesale violation of Muslims’ civil rights.

And Eure actually agreed. Last summer, he said a probe of five years’ worth of data found no “improper motives” and a “valid basis for commencing investigations” in each case — in compliance with guidelines Judge Haight himself had set down.

But Eure’s report played up missed deadlines — and the judge has taken that as license to demand a retooled settlement, and perhaps even installing yet another federal monitor over the department.

The NYPD’s mission is to keep New York safe from criminals and terrorists, and it fulfills that mission daily. Yet, thanks to the mayor’s political pandering to his left flank, New York’s Finest may soon be hamstrung by yet another layer of civilian and judicial micro-managers.