Austria's new president has vowed to listen to the people's "fear and anger" after his far-right opponent narrowly missed out on a landmark victory.
Independent Alexander Van der Bellen beat the Freedom Party's Norbert Hofer by just 31,000 votes among the 4.64 million cast in Sunday's election.
The victor accepted there was a "rift" but said: "We are two sides of the same coin. Together we make up Austria."
Mainstream European politicians expressed relief at the result.
If he had won, Mr Hofer would have become the first far-right head of state of a European Union nation.
German Foreign Minister Frank-Walter Steinmeier said all of Europe was "breathing more easily''.
And French Prime Minister Manuel Valls said it was a "relief" to see Austrians "reject populism and extremism".
Mr Hofer had run on a Eurosceptic, anti-immigration platform. Many nations have seen a surge in nationalist and anti-immigration parties amid the migrant crisis and economic uncertainty.
'Non-partisan president'
In his victory speech, Mr Van der Bellen, a pro-EU candidate backed by the Greens, said he accepted that many people believed that they were not being heard.
He said: "We need a different culture of dialogue and a political system which deals with people's fears and anger."
Mr Van der Bellen, 72, said he would "work towards winning the trust of Norbert Hofer's voters" and try to be "a non-partisan president for all the people in Austria".
He added: "There's been a lot of talk about this country's rifts. But I think you can also interpret the split as a sign that we are two sides of the same coin and each side is as important as the other."
While he awaited the result, the man who could have become the EU's first far right leader mowed his lawn. I met Norbert Hofer in his hometown — about an hour's drive from Vienna. We chatted at his garden gate — he was still perched on his ride-on lawnmower.
These elections, he said, would go down in history. And, he told me, whoever won would have to work to unite this country.
Perhaps he's right. The election has split Austria and exposed, once again, deep divisions in Europe — how to deal with the migrant crisis, the economy and how to balance national interests against those of the EU.
And what's characterised this vote — widespread disillusionment with the political mainstream and growing support for Mr Hofer's far-right Freedom Party — is reflected across a growing number of European countries.
Chancellor Christian Kern said the vote was "worryingly close… and therefore it is of particular importance to us that… no voter feels like they have lost."
The Austrian presidency is largely a ceremonial post. But the president can dissolve the lower house of parliament and call elections without the need for permission from the ruling party.
'Gigantic showing'
Mr Hofer said on his Facebook page (in German) it was a "sad day" but added: "Please don't be disheartened. The effort in this election campaign is not wasted, but is an investment for the future."
Freedom Party leader Heinz-Christian Strache said: "This is just the beginning."
France's National Front praised a "historic performance".
Mr Van der Bellen and Mr Hofer were contesting the run-off after the candidates of the two parties that have dominated Austrian politics since World War Two were eliminated.
Opinion polls suggest that if parliamentary elections were held now, the Freedom Party would win. The next polls are scheduled for 2018.
Alexander Van der Bellen
Alexander Van der Bellen is the first environmental activist to become Austrian president. He is a chain-smoker and left-leaning liberal committed to the EU.
He is the son of aristocratic refugees from Russia's 1917 Bolshevik Revolution. First they escaped from Pskov to Estonia, then in 1940 they fled the Soviet occupation — the communist takeover of the Baltic states.
The family settled in Austria's Tyrol region. Alexander grew up in Kaunertal and does not speak Russian. His surname harks back to Dutch ancestry.
He studied economics at the University of Innsbruck and was later appointed professor at Vienna University. He retired from academia in 2009.
He was elected to parliament for the Greens in 1994, and from 1997-2008 was the party's spokesman.
In a TV debate, one of the few things he agreed on with Mr Hofer was that neither would accept TTIP — the free trade deal the EU is negotiating with the US.
The breakdown of the vote
In nine out of Austria's 10 main cities Mr Van der Bellen came top, whereas Mr Hofer dominated the rural areas, the Austrian broadcaster ORF reported (in German).
Support for Mr Hofer was exceptionally strong among manual workers — nearly 90%. The vote for Mr Van der Bellen was much stronger among people with a university degree or other higher education qualifications.
Support for Mr Hofer among men was 60%, while among women it was 60% for Mr Van der Bellen.