How much punishment must liberal elites on both sides of the Atlantic endure before they learn not to try to undo the will of voters? That such trickery only invites fiercer and more decisive popular backlashes?

This week, elites on both sides of the Atlantic had their knuckles rapped on ­exactly these points — yet again. The United Kingdom finalized its divorce, once and for all, from the European Union — despite three years of underhanded ­efforts from “Remoaners” determined to keep the marriage going.

On our side of the pond, meanwhile, the dreary, ­exhausting and pointless ­impeachment drive well and truly petered out.

Start with Britain and ­Europe. The European Parliament on Wednesday ratified the withdrawal agreement struck by UK Prime Minister Boris Johnson and the Brussels mandarins. Brexit is happening, finally — Friday at midnight Belgian time, to be exact.

“Brexit is a defeat, a rebellion against the concept that working together makes ­Europeans stronger,” German Marshall Fund fellow Rosa Balfour told the New York Times. As usual, the Gray Lady turned to a spokesman for the professional-managerial classes.

They believe that global liberalism is destined to overcome nations, borders and other vestiges of the dark, unreasonable past. Thus, a vote for Brexit was a blow to the very concept of cooperation.

Of course, ordinary Europeans know that cooperation between nations doesn’t require a massive, unaccountable bureaucracy running a whole continent — a pseudo-Christendom without the beauty and soul of the real thing.

As Brexit pioneer Nigel Farage said in his swan-song speech to the European Parliament on his way out: “If we want trade, friendship, cooperation, reciprocity, we don’t need a European Commission, we don’t need a ­European court, we don’t need these institutions and all of this power.” He added: “We love Europe, we just hate the European Union.”

Along the way, Farage ­recounted all the ways Brussels had run roughshod over the popular will in its quest for “ever-greater integration.” When European voters ­rejected EU power grabs at the ballot box, they had the measures rammed down their throats anyway, via treaties and bureaucratic fiat. In other cases, disobedient voters were simply forced to vote again until they reached the “right” outcome.

When Britons voted to get out of the EU, it took three years of political combat against Brussels and the UK’s own pro-EU elites to realize the aspiration they had expressed in record numbers in the 2016 referendum.

Every element of establishment power — from the Bank of England to the BBC, from the universities to the Church of England, from the civil service to the world of high finance — mobilized in the effort to kill Brexit.

They tried every trick in the book. They endlessly slow-pedaled Brexit in Parliament. When Johnson temporarily and legally suspended Parliament in an ­effort to end the endless discussion, they got activist judges on the high court to stop him.

They tried to destroy the lives of Brexit activists. The Electoral Commission fined a young Brexiteer £20,000 because he checked the wrong box on an application form.

And, of course, they pushed the ludicrous notion that Brexit was the nefarious work of — you guessed it — the Russians.

Finally, it all failed. Late last year, voters sent Johnson to No. 10 Downing Street with a resounding majority and a clear mandate to get Brexit done.

“You’re very good at making people vote again,” Farage declared. “But what we’ve proved is that the British are too big to bully — thank goodness!”

Indeed.

If that pattern of elite misbehavior sounds familiar, it’s because Democrats and Never-Trump elites have for three years been up to the same thing here in the United States. They took President Trump’s victory as an insult to their professional-managerial honor — and they were determined to punish him and his voters.

Instead of taking stock of their own policy failures, which had battered working-class Americans of all races, they resolved that Vladimir Putin had hypnotized half the country with his Twitter bots and planted a Manchurian Candidate at 1600 Pennsylvania Ave.

The Mueller report utterly debunked that theory. The special counsel concluded that there was no evidence of collusion between the Trump campaign and the Kremlin.

For liberals, the sane thing to do at that point would have been to focus on booting Trump from office the normal way: by trying to beat him fair and square at the ballot box in 2020.

But no: The trauma of 2016 was too wounding. Trump shouldn’t have become president, and so they would use impeachment to retcon history and erase the Bad ­Orange Event. They came up with a cockamamie Ukraine impeachment theory based on third-hand information and no evidence of lawbreaking. And now that’s going exactly nowhere.

Especially in an age of populism, the way back to the electorate’s heart lies through politics — not procedural tricks. The sooner the left learns this, the sooner its agony will end.

Sohrab Ahmari is The Post’s op-ed editor. Twitter: @SohrabAhmari