VIENNA (Reuters) - Austrian voters roundly rejected on Sunday a candidate vying to become the first freely elected far-right head of state in Europe since World War Two, halting at least temporarily the wave of populism sweeping Western democracies.

The runoff vote was a litmus test, since it was a re-run of a vote held in May, before Britain voted to leave the European Union and Americans elected Donald Trump as president.

Norbert Hofer of the anti-immigration Freedom Party lost the May election by less than a percentage point, and polls had for months shown the race too close to call.

But within minutes of polls closing it was clear he had lost to former Greens leader Alexander Van der Bellen, who had put the June Brexit referendum at the center of his campaign, saying Hofer would lead Austria down the same road as Britain and warning voters not to “play with this fire”.

“A red, white and red signal of hope and of positive change is being beamed from Vienna through Europe,” Van der Bellen said in a victory speech, referring to the colors on Austria’s flag. “I will be a pro-European president of Austria open to the world.”

With only postal ballots left to count, a projection by pollster SORA for broadcaster ORF showed Van der Bellen on 53.3 percent and Hofer on 46.7 percent with a margin of error of 0.4 percentage points.

Turnout was roughly a percentage point higher than in May, at 74 percent. That election had to be re-run because of irregularities in counting the votes.

The result dealt a blow to populists who had hoped anti-establishment anger had grown enough since the Brexit referendum and Trump’s triumph to sweep Hofer into office. The closely watched vote also came before elections in France, Germany and the Netherlands next year.

European governments breathed a sigh of relief at the result, as they had done after the May runoff.

“A weight has fallen from all of Europe’s shoulders,” said German Vice Chancellor Sigmar Gabriel, a Social Democrat. “If the projections are confirmed, the result of the election in Austria is a clear victory for reason against right-wing populism.”

What effect the Brexit and Trump votes had on the Austrian election is not clear.

Data from SORA showed that Van der Bellen’s pro-European stance was his supporters’ second-strongest reason for voting for him, cited by 65 percent of them, just behind the view that he would best represent Austria abroad.

Among Hofer supporters, the top reason was that he “understands the concerns of people like me”, cited by 55 percent of respondents.

Slideshow ( 13 images )

‘INFINITELY SAD’

With one blow to Europe’s political establishment averted, a potentially bigger one looms. Italy is holding a referendum on Sunday on constitutional reform that could decide the political future of Prime Minister Matteo Renzi, who has promised to resign if he loses.

There is also the more distant prospect of a clash between Van der Bellen and the Freedom Party - the FPO - in the event of an FPO victory in parliamentary elections. The president plays an important role in the formation of coalitions after an election, and Van der Bellen has said he would try to prevent an FPO-led government.

Slideshow ( 13 images )

“I am infinitely sad that it didn’t work out,” Hofer said on his Facebook page less than an hour after polls closed, later adding that he would run again in the presidential election in six years.

He said he would now turn his attention to running for parliament in an election due by 2018. Polls suggest the FPO would win that election, since it now has the support of roughly a third of voters, well clear of its nearest rival.

“Congratulations to the FPO, which fought valiantly. The next legislative elections will show their victory!” tweeted Marine Le Pen of France’s National Front, an FPO ally who will contest the French presidential election next year.

Austria has for decades been dominated by two centrist parties that are once again in coalition, and anger at that entrenched duopoly has fueled support for the FPO, which wants to end the two parties’ grip on power.

There has been speculation about whether Chancellor Christian Kern’s Social Democrats and the conservative People’s Party will manage to keep working together until their mandate expires in 2018.

“I don’t think this government will last much longer,” Hofer said.

For now Austrians will be glad to put behind them the comedy of errors that meant this election dragged on for almost a year, prompting some media to label the country a “banana republic”.

The result of the May 22 runoff was overturned mostly due to election officials cutting corners as they raced to complete the count. The re-run was then postponed because the glue on the envelopes for some postal ballots did not stick.