Elder statesman Alexander Van der Bellen beat back the far-right insurgent candidate in Austria’s high-stakes presidential race, claiming a wafer-thin victory in the final count Monday after a campaign that exposed the rise of populism in the West.

Van der Bellen, 72, had fallen behind in the election-day vote Sunday but edged out Norbert Hofer, a 45-year-old aeronautical engineer from the far-right Freedom Party, after winning a majority of the hundreds of thousands of absentee ballots counted Monday. The Austrian Interior Ministry declared Van der Bellen, a longtime Green Party politician running as an independent, the victor with 50.3 percent of the vote to Hofer’s 49.7 percent.

Across Europe, mainstream politicians breathed a sigh of relief even as the election offered fresh insights into the voting trends that may influence bids for high office by other populists, including Donald Trump in the United States and Marine Le Pen in France. Hofer was ultimately undone by a coalition of female, better-educated and urban voters who were less interested in supporting his opponent than defeating him.

Had Hofer won, he would have become the most senior standard-bearer of the far right in Western Europe at a time when nationalist populists already hold sway in Eastern European countries, including Hungary and Poland, and have launched aggressive campaigns against the media and critics. A Hofer victory would have pushed populism into Europe’s core, proving that such platforms can win elections even in wealthy, economically advanced societies.

Hofer had campaigned against migrants and Muslims and in favor of gun rights and low taxes. He shocked many Austrians — and Europeans more broadly — by coming in first in an initial round of voting last month. In contrast, Van der Bellen preached tolerance and inclusion, a message that just barely secured him the presidency.

Speaking to the nation Monday evening, Van der Bellen said he had run a campaign that sought “to stress the common good and put that above what separates us.” But he also acknowledged the voter wrath with traditional politicians that nearly led to the election of a far-right president.

“We are going to need a different culture of talking to each other, a politics that is less focused on itself and the media and more on the real worries and real fears and also the anger of people in this country,” he said.

“Please don’t be disheartened,” Hofer told his supporters while conceding defeat on his Facebook page. While admitting he was “sad” to lose, he said that “the support for this campaign is not lost, but an investment in the future.”

The Freedom Party’s secretary general, Herbert Kickl, sounded a defiant note, telling Austria’s public broadcaster ORF that the result shows his party is “well positioned” for parliamentary elections in two years. He also said the party would consult Tuesday about technical aspects of the vote and reserved the right to contest the result if it finds any “deficits.”

Politicians elsewhere in Europe, meanwhile, hailed the result as a near miss.

“It’s a good day for Austria and a good day for Europe when the candidate of the right-wing Freedom Party isn’t able to assert himself,” said Katarina Barley, secretary-general of Germany’s Social Democratic Party.

The job of president in Austria is largely ceremonial. But Hofer’s vow to flex the muscles of the office, even threatening to dismiss the sitting government if it didn’t control migration, turned what normally would have been a staid election into one that was closely watched across Europe. It also offered a glimpse into the kind of voting behavior that may make or break the prospects of other populists gunning for power, including Trump and Le Pen.

Van der Bellen did not particularly excite Austrian progressives: Polls showed that almost half of those who voted for him did so primarily to stop Hofer from winning. Turnout was relatively high, at 72.7 percent, suggesting that both sides had managed to mobilize large numbers of voters.

The polls — targeting likely voters and commissioned by ORF — also showed that Hofer was popular with male voters, while Van der Bellen appealed more to women and the young and better-educated. Rural voters tended to favor Hofer, while his opponent scored higher in cities.

Some observers have tied Hofer’s rise to historical far-right roots in Austria, a country often perceived as never having quite dealt with its wartime Nazi sympathies. Yet other analysts suggest a phenomenon more similar to the one that has millions of Americans supporting Trump.

“Trump is a completely different personality. He’s a big-mouth, an elephant in a china shop, whereas Hofer comes across as more polite,” said Peter Hajek, a Vienna-based political analyst. “But the voters are very similar.”

Although Van der Bellen’s narrow victory fended off a Hofer presidency, analysts said the election might have done damage to the nation, arguing that the winner must now seek to heal wounds in a deeply divided country.

Green Party politician Sven Giegold tweeted: “The close race is covering up the big picture: It’s a low point for democracy in Europe, when 50 percent are voting for a right-wing populist.”

Stephanie Kirchner contributed to this report.