It was like Bernie Sanders vs. Donald Trump in the heart of Europe, and the Bern won by a nose.

Left-wing economics Prof. Alexander Van der Bellen was elected Austria’s largely ceremonial president, holding off an anti-immigration nationalist who campaigned on a Trump-style “Austria First” platform.

But the nail-biter margin — 31,026 votes out of nearly 4.5 million cast — signified polarization, and gridlock, more of a defeat for the crisis-plagued European establishment than a victory of an alternative political program.

The tight vote “indicates not so much the strength of the extremes, but the weakness of the center,” said Timo Lochocki, a fellow at the German Marshall Fund in Berlin. “You win elections if you polarize and personalize and have a story to tell.”

Austria was fertile ground because it’s been governed by a cozy twosome of center-left and center-right parties for most of the post-World War II era. With Austria’s mainstream parties blurring together and divvying up posts and patronage, the opposition was banished to the fringes. That ostracism ended in the first round on April 24 when candidates from the two traditional parties were eliminated.

“It’s a Europe-wide trend: The economic good times are over, and the search is on for new policies,” said Peter Hajek, a public opinion analyst in Vienna. “And that’s where there’s a divergence of views.”

For some, the triumph of Van der Bellen, 72, over the Freedom Party’s Norbert Hofer showed the right can be stopped. Austria will get a Green Party-backed president to go along with a Social Democratic chancellor. For the Freedom Party, the near-miss was just a steppingstone to taking over the chancellorship, the real seat of power, in the next elections in 2018.

Still, the electoral close call demonstrated that, in countries north of the Alps, the anti-immigrant variant of populism strikes a chord with voters. even in an era of relative prosperity.

Austria has the third-lowest jobless rate in the 19-nation eurozone, at 5.8 percent. Germany’s 4.2 percent rate hasn’t prevented the rise of fledgling anti-euro, anti-immigration party there.