VIENNA, May 23 (Reuters) - 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.
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.