Emerging from his hidey-hole to give a midday speech yesterday, Mayor Bill de Blasio bore a suitably funereal demeanor. He called for all New Yorkers to embrace and respect the families of the slain police officers, and urged a moratorium on protests until after the officers were laid to rest.

His prepared remarks were pedestrian, but appropriate in tone and substance, and well received by a friendly audience. Facing his first real crisis in City Hall, he seemed to be doing his best to hold his own emotions in check and hold the city together.

Then he blew it. Late in the day, the mask of conciliation came off. Actually, he ripped it off with a snarl and gave vent to his smoldering anger at what he regards as the real culprit.

No, it’s not the protesters who beat and spit on cops and accuse them of being the KKK. It definitely isn’t the mobs chanting for dead cops. Nor is it those who shut down highways, bridges and invade stores to disrupt the holiday season.

The real problem, as de Blasio sees it, is the media. I kid you not — he actually shot the messenger.

He accused the reporters assembled in front of him of stoking outrage by focusing on “the few” protesters doing “immoral” things.

“They are wrong,” he said, his voice rising.

“But are you going to keep dividing us? What you manage to do is pull up the few who do not represent the majority.”

He called it “unfair,” and insisted most protesters were peaceful but that “you guys enable” the troublemakers.

He went on in that vein for several minutes, becoming more forceful and shutting down a persistent reporter by addressing him as “my friend,” a phrase he paired with a death stare.

Rather than convince, the tirade revealed. Like looking at an X-ray, we saw the real de Blasio. It wasn’t a pretty sight.

His heart remains with the protesters, and in spirit, he is still with them, denouncing the very police force that works for him. His passion for the anti-cop agenda is so deep that he wasn’t capable of following his own advice to take a break from divisiveness for even a single day.

The mayor’s intemperate performance was unforgettable, and unforgivable. Any hope that he would own up to the fact that he contributed to the atmosphere that led to Saturday’s bloody explosion was dashed.

Most important, it is unlikely that he will be able to lead the city forward or even back to where it was when he took office. He clearly continues to believe that there is something wrong with the NYPD, something fundamental that he is determined to fix, whatever the cost in civic harmony.

Polls show most New Yorkers don’t agree with him.

Of course, there is room for police improvement and, once he was elected, most would have backed a moderate, deliberate program of reform.

Instead, he launched a relentless assault on the greatest force for good Gotham has ever seen, and helped to unleash a fever that leaves no room for nuance or debate.

The result is an unsettling polarization that makes everything worse for everybody.

For de Blasio to see that stark division, and insist the media is to blame, is tantamount to painting himself as a victim.

He’s free to believe that, but he’s in the wrong business, or at least the wrong position.

As a councilman or public advocate, he could be the radical pol who marched for the cameras, got arrested and made wild charges against “the man.”

Nobody cared or noticed.

Better yet, he could have skipped government and become a go-fer for Al Sharpton, maybe rising to deputy organizer.

It’s easy to imagine him wielding a bullhorn and a clipboard and leading chants of “No justice, no peace.”

Unfortunately, de Blasio opted for another path, thinking that as “the man,” he would be in a position to remake New York.

He could stir marginalized blacks, anarchists and rootless young people by invoking Jim Crow segregation and accusing NYPD bosses of being modern-day Bull Connors.

None of it is true, but facts don’t matter to him.

He’s a believer. Like most radicals with no real-world experience, he assumes the way to fix things is to first smash them into pieces. That’s what he’s doing to New York.