Independent candidate Alexander Van der Bellen had already won the contest once, back in May.
Independent candidate Alexander Van der Bellen had already won the contest once, back in May -- the election had to be held again because of procedural problems -- so in theory the 72-year-old could do it again.
But a lot has happened since May to boost the confidence of populists like his far-right rival Norbert Hofer, not least Britain's shock decision in June to leave the EU and Donald Trump's US election victory last month.
"Today I was totally surprised because after Trump and Brexit I was really not sure what this meant for Austria," diplomat Wolfgang Pietrisch, 69, said at Van der Bellen's election party.
"I was hugely surprised and my confidence, which was rather low in the past couple of days, went up -- skyrocketed," Pietrisch told AFP.
At the same event, artist Natalia Nadasma, 21, said that Brexit and Trump had motivated many activists to make sure that the Austrian election wasn't yet another political shock.
"A lot of people from civil society decided to be active, to go onto the streets in order to convince people to vote for liberalism, to vote for openness, to vote for diversity," Nadasma said.
Student David Sheata, 20, said he had been worried that after being asked to vote no fewer than three times this year -- and for what is a largely ceremonial job -- voter fatigue would set in.
But not a bit of it. The result was "a big surprise because we all thought that Hofer will win because Austrians lost their trust in the election process. But now, after the first result, we are very happy."
In fact, according to Van der Bellen, turnout was around 75-76 percent -- higher than in May.
Political analyst Peter Hajek said that Van der Bellen's supporters did a good job in the past few weeks getting people out to vote.
Campaigners used Brexit and Trump to say to people "if you don't want to end up also wondering what happened, then go out and vote, and vote Van der Bellen," Hajek said.
Sandra Edelmann, 30, a corporate consultant waving a rainbow flag and wearing a "Fan der Bellen" T-shirt, said she had never given up hope.
"I believed and hoped that Austria would be clever enough to vote Van der Bellen, and they were," she told AFP.
"In the last 11 months I have been very active in the campaign. Last night I was in the pubs til 2:00 am, talking to people, motivating them," said social worker Christoph Krottmayer, 35.
"I am very relieved. It was all worth it. Later I think I might cry out of relief."
But amongst Hofer's supporters, the disappointment was huge for those hoping he would be able "get rid of the dusty establishment", as the candidate put it.
"I think it's clear that not a lot is going to change in Austria," said Johannes Huebner, 60, a lawmaker from Hofer's anti-immigration Freedom Party (FPOe).
"Van der Bellen as president will provide a certain security for both parties in the government that they can just carry on as before."
Herbert Kickl, the FPOe's general secretary and chief strategist, put a positive spin on Hofer's defeat, saying it would make the party stronger ahead of the next parliamentary elections, due in 2018.
"Norbert Hofer closed the gap with the main representative of this whole system, giving us a sustainable gain that we can use for our political movement but also for possible parliamentary elections," he said.
For the most part, Hofer supporters were hard to find at FPOe headquarters on Sunday night. But on the internet, where the party has an immense presence, the anger was palpable.
"I am just appalled and shocked!" said Regina Sassmann, one of almost 700 people to react to FPOe leader Heinz-Christian Strache's post-election post on Facebook. "Austria has voted for its own downfall! Well done!"
"I am really thinking about leaving this country for good," bemoaned Manfred Stadler. "I can predict that pretty soon we will be betrayed by the EU and overrun by radical refugees. I can't be bothered wasting my energy and my money."