Mayor Bill de Blasio was in his element Friday: pandering to the annual assembly of the nation’s largest teachers union by smearing charter schools.

Charters are alternative public schools that operate outside the usual bureaucracy — and typically without unions, which makes them anathema to the National Education Association crowd de Blasio addressed.

Well, that and the fact that they regularly outperform unionized schools — a strong sign that excessive teachers union power is part of the problem in US public education.

So the crowd loved the mayor’s lies, starting with his attack on a total red herring: supposed “efforts to privatize a precious thing we need — public education.”

In fact, charters are fully public schools: publicly funded and serving the very same population. They’re also publicly accountable: A charter that’s not working can be shut down by the same public authority that issued its charter in the first place.

Yes, some charters get added cash from donations — but so do plenty of regular public schools. Heck, Dante de Blasio went to Brooklyn Tech, which has a sizable endowment thanks to private gifts.

No matter: The mayor claims the movement is an evil plot, thundering, “No one should be the Democratic nominee unless they’re willing to stand up to Wall Street and the rich people behind the charter school movement once and for all.”

In fact, the “people behind the charter school movement” include ex-President Barack Obama and his education secretary, Arne Duncan: They refused to accept the failure of regular US public schools when it comes to offering real opportunity to lower-income, minority children.

Those two, along with countless other progressives, are who de Blasio was damning when he said “too many Democrats have been cozy with the charter schools.”

The mayor wasn’t the only 2020 hopeful to pander shamelessly. Sen. Liz Warren denounced “high-stakes testing,” which she had long supported as vital to boosting the education of those same low-income black and Hispanic kids.

And all 10 of the candidates who appeared, including Obama’s vice president, Joe Biden, vowed to name a career “educator” to run the Education Department — a union litmus meant to shut out innovators like Duncan.

Only Beto O’Rourke stood up for charters, the most promising educational reform in America. The rest simply promised more pay and more power to the unions. Pathetic.