Bret Stephens made a mistake. Everyone who follows stories about the media knows this, though blessed are those who don’t follow such squalid matters.

A recent tweet from a relatively unknown college professor comparing him with a bedbug sent the New York Times columnist into a transport of rage. Stephens emailed the prof to reproach him for his incivility. He carbon-copied the school’s provost for good measure.

There is no point trying to defend Stephens’ action on the merits. It would have been one thing, perhaps, to berate the prof privately — but to drag in his university boss can’t but appear hypocritical, coming from a scribe who has devoted hundreds of column inches to denouncing the so-called cancel culture and censorious campus progressives.

But the internet-wide campaign to ridicule Stephens is as repellent and wrong as it is routine in our age of online mobs.

Here is what I do know about Bret Stephens: He is more, much more than an email fired off in a rash, heated moment. Whatever his foibles — and like all of us, he has his share — Bret is also possessed of a generous spirit and more journalistic integrity and scrupulosity than nearly all of the people I have encountered in this business.

If you think I’m saying all this because he gave me my first job, at the Wall Street Journal nearly seven years ago, keep in mind that Stephens recently wrote a column portraying me as his protégé-gone-wrong and a “would-be theocrat.”

We have profound disagreements about the purpose of politics: The rise of populism across the West has seen Bret embrace a purer form of classical liberalism, while I have drifted toward a more socially conservative, and distinctly Catholic, politics.

I find myself coming to Stephens’ defense all the same, because he was the guy who taught me to always give the target of a polemical piece a chance to respond to my accusations, even if that meant sitting on a piece that would have been “hot” online. Stephens was the mentor who would generously compliment my prose — but also call me out when I caricatured the other side’s argument or didn’t give the other side its due.

Stephens was the boss who urged me to ‘fess up to even minor factual errors and run corrections as soon as possible, rather than “ninja-fix” things online or pray no one would notice. He was broad-minded enough to be able to put himself in the shoes of even regimes and causes he detested; he could see why China’s Communist leaders might think or behave a certain way, even as he skewered them in print. He lived by the French proverb that “To understand everything is to forgive everything,” and he tried to understand a great deal.

Here is another thing I know about Stephens: The Nazi Holocaust deeply scarred his Jewish forebears in Europe; it shattered them. I remember him telling me once about how in a single day, the Nazis, in cahoots with Lithuanian locals, massacred 10,000 Jewish men, women and children in his mother’s ancestral town. So I can see why the prof’s likely innocent analogization to bedbugs got under Stephens’ skin in a way that others may not understand.

To understand everything is to forgive everything. I can understand how someone who enjoys a massive media platform might, in a moment of emotional weakness or volatility, lash out at someone who is objectively “weaker” than he — to punch down, as it were. I can understand that, because I’ve done that. And Stephens has often been the one to gently call me out for it and urge me to do better.

Bret Stephens is more than one silly email. And if you are tempted to join the pile-on, don’t. It won’t do you any good, and it might even do your soul some harm.

Sohrab Ahmari is The Post’s op-ed editor.