Heinz-Peter Bader / Reuters Presidential candidate Norbert Hofer arrives at the party headquarter of the Austrian Freedom party (FPO) in Vienna, Austria, April 24, 2016.

VIENNA, April 24 (Reuters) - Austria's far right won more than a third of the vote in the presidential election on Sunday and will face an independent in next month's run-off, dumping out the country's two main parties from the post for the first time.

It was the Freedom Party's best result in a national election after a campaign that focused on the impact of the migrant crisis, which has seen around 100,000 asylum seekers arrive in Austria since last summer.

Norbert Hofer, who ran on an anti-immigrant and anti-Europe platform, won 36.4 percent of the vote to become head of state. He will face Alexander van der Bellen, a former Green Party figurehead, who won 20.4 percent, according to official preliminary results.

While the presidency is largely only a ceremonial role, the fact that neither of the main ruling parties will be battling for the post on May 22 marks a major change in Austrian politics - as well as the rising role of the far right in Europe.

Members of the center-left Social Democrats and the conservative People's Party have filled the job since it was first put to a popular vote in 1951. The two parties have ruled the nation of 8.7 million in tandem for most of the postwar era.

The president is head of state, swears in the chancellor, has the authority to dismiss the cabinet and is commander in chief of the military.

The election outcome was "a resounding slap in the face" for the government coalition, said Wolfgang Bachmayer, who founded the OGM market research institute.

His comments were echoed by political analyst Peter Filzmaier. "Only those who are satisfied vote for a government party or its candidate," he said. "This time, the annoyed voted for Norbert Hofer."

Anadolu Agency via Getty Images Presidential candidate of Green Party, Alexander Van der Bellen casts his ballot at a polling station during Austrian presidential elections in Vienna, Austria, on April 24, 2016.

"FOOD FOR THOUGHT"

Around 70 percent of eligible voters cast their ballots, a big turnout compared with around 50 percent six years ago when Social Democrat Heinz Fischer, now 77, was elected for his second term. He could not run for a third term.

Peter McDonald, general secretary of co-ruling People's Party acknowledged the scale of the defeat after coming in fifth in the poll with just 11.2 percent of the vote.

"We have experienced a landslide that should give the entire political center food for thought," he said.

The social democratic Chancellor Werner Faymann, whose party ranked fourth, said the outcome was a clear warning to the government to work harder and cooperate better.

Should Hofer get the top job, he could push to bring forward a parliamentary election due to take place in 2018 as support for his party has been growing.

Polls show the Freedom Party above 30 percent, while the coalition parties would struggle to get a combined majority.

Showing the far right's growing confidence in Europe, Marine Le Pen, leader of France's National Front, hailed a "beautiful result," writing on Twitter: "Bravo to the Austrian people."

Both the candidates that made it through to the run-off had taken aim at the government over its handling of the migrant crisis. Van der Bellen criticized the government for being too harsh in its treatment of asylum applicants, while Hofer says it has been too soft.

"It could hardly be any more dramatic," said political consultant Thomas Hofer, adding that he thought Van der Bellen would face a difficult task to win the run-off with the gap between him and Hofer.

Neither Faymann nor Vice Chancellor Reinhold Mitterlehner from the People's Party said they would make any recommendation for the run-off. Voters should decide independently, they said.