Austria has elected a 72-year-old former leader of the Greens party to be its next president, narrowly avoiding becoming the first country in the European Union to vote in a far-right candidate as head of state.
After an election on Sunday that was too close to call, Austrian officials spent most of Monday counting hundreds of thousands of postal ballots which ended up vaulting Alexander van der Bellen past Freedom Party rival Norbert Hofer and into the ceremonial post of president.
The Interior Ministry gave van der Bellen 50.3 percent of the vote, compared to 49.7 percent for Hofer, who had run on an anti-immigration platform.
Hofer conceded defeat in a post on his Facebook page, thanking his supporters and telling them not to be despondent.
"Of course I am sad today," he said. "I would have liked to take care of our wonderful country for you as president."
Hofer's defeat averts an embarrassing setback for Europe's political establishment, which is increasingly under threat from populist parties that have profited from concerns about the region's refugee crisis and years of weak growth and high unemployment.
"It's a relief to see the Austrians reject populism and extremism," French Prime Minister Manuel Valls said in a Twitter post. "Everyone in Europe must draw lessons from this."
Austria is a relatively prosperous country, but it has been at the center of a record influx of migrants from the Middle East, fanning public resentment towards the two centrist parties - the Social Democrats (SPO) and the conservative People's Party - that have dominated politics since the end of World War Two.
In part, that sentiment echoes similar frustrations with mainstream politics across the West. But "Austrian duality again complicates the picture," as The Christian Science Monitor reported:
The Second Republic successfully portrayed Austrians as the first victims of Nazi horror, while denying the roles of so many as loyal Nazis. Later, "Austria was treated by the Allies as a liberated and occupied country at the same time," [Professor Anton] Pelinka says, "liberated from Nazi Germany but occupied like Germany."
And then as domestically Austria became a fully Western democracy, officially it declared its neutrality in 1955. "Internationally it was neither East nor West," says Pelinka. "It's a rather convenient position. No one dares touch [it]. But it's not an active position."
Michal Vašečka, a Slovak sociologist and professor at Masaryk University in Brno in the Czech Republic, says that this matters today because the countries that were under the Austro-Hungarian empire never "properly reconciled with Nazism, Fascism, or the results of World War II," he says. Because of this, unlike Germany where the far-right is growing but remains on the fringes, hateful rhetoric finds more fertile ground here.
Sunday's provisional result, which did not include the postal ballots, showed Hofer ahead with 51.9 percent to van der Bellen's 48.1 percent.
But the SORA institute, a pollster, had said that mail-in ballots were likely to favor van der Bellen because they are traditionally used by more educated voters. The institute's election-day polling showed 81 percent of voters with a university degree had backed van der Bellen and 86 percent of workers voted for Hofer.
The vote in Austria, a country of 8.5 million people, had unsettled leaders elsewhere in Europe, particularly in neighbor Germany where a new anti-immigration party, the Alternative for Germany (AfD), is on the rise.
In France, the National Front of Marine Le Pen is leading in polls ahead of a presidential election next year. Across the Channel, the UK Independence Party is campaigning for Britain to leave the European Union in a referendum on June 23.
Hofer, 45, has described himself as a center-right politician and told voters not to believe suggestions from other parties that he would be a dangerous president.
But his party has its roots in Austria's Nazi past, a history the country has not confronted as openly as Germany.
Writing by Noah Barkin; Editing by Mark Trevelyan