Van der Bellen beat Hofer of the anti-immigrant, populist Freedom Party with 50.3 percent to 49.7 percent — “a difference of 31,026 votes,” Interior Minister Wolfgang Sobotka said during an official announcement in Vienna.

“Of course I am sad,” Hofer said on Facebook as he conceded defeat, but added: “Please don’t be disheartened. The effort in this election campaign is not wasted, but is an investment for the future.”

Preliminary results late Sunday had put Hofer barely four points ahead in the runoff for the largely ceremonial but bitterly fought-over post of Austrian head of state.

But his paper-thin margin was erased after a record 700,000 postal ballots were counted during Monday, dramatically putting Van der Bellen ahead by just over 31,000 votes in the final tally.

Turnout was at almost 73 percent, high for European elections.

Most observers had thought that Van der Bellen, 72, an independent who stood with Green Party backing, would fail to beat his polished younger rival after lagging 14 points behind him in the first round on April 24.

“But in the last 14 days, there has been such a momentum among voters… (across) all sections of society,” the professorial Van der Bellen said late Sunday.

Gun enthusiast Hofer, 45, had tapped into unease about the record number of asylum seekers at the height of Europe’s migrant crisis, with his typical supporters made up of lesser-educated working-class men and in rural areas.

But the self-proclaimed “gladiator” has also toned down the FPOe’s message to win voters across the spectrum disillusioned with the centrist parties in the current government that have dominated national politics since 1945.

His strategy mirrored the success of other fringe political figures across Europe, most recently in elections in Cyprus on Sunday, as well as further afield as seen with the success of Donald Trump in the United States.

Van der Bellen said Monday he would seek to unite the deeply divided nation, after he narrowly beat his far-right rival Norbert Hofer in a knife-edge runoff.

“A lot of people in this country evidently feel that they aren’t being seen or heard enough,” he said in his first official speech in Vienna following the result announcement.

“We need a different culture of dialogue and a political system which deals with people’s fears and anger… I will also work toward winning the trust of Norbert Hofer’s voters.”

The Green-backed economics professor won 50.3 percent of the vote in Sunday’s second-round, marginally ahead of 49.7 percent for Hofer, presented as the friendly and moderate face of the anti-immigration, populist Freedom Party (FPOe).

With almost half of the votes cast, or 2.2 million people, going to Hofer, Van der Bellen now has to unite a polarised nation after a bruising election campaign.

“I want to be a nonpartisan president for all the people in Austria,” he said.

“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. Together we make up Austria,” he added.

Van der Bellen will replace outgoing President Heinz Fischer of the Social Democrats (SPOe) on July 8.

Fischer, who took office in 2004 and was re-elected for a second term six years later, has enjoyed huge popularity during his long tenure.

“The biggest duty of the new president will be to bridge the divides,” Fischer said.

Chancellor Christian Kern said Van der Bellen “represents a stance that is pro-European, open to the world and for a policy that puts opportunity in the forefront and which doesn’t stoke fears”.

But “we must remember that the election result was achieved with a worryingly close lead, and therefore it is of particular importance to us that… no voter feels like they have lost,” added Kern, himself a newcomer to the government.

He was sworn in earlier this month after fellow Social Democrat Werner Faymann quit over the historic first-round defeat in the presidential race of the long-powerful SPOe and their coalition partner, the centre-right People’s Party.