(CNN) Austria could go from having a left-leaning president-elect to a far-right one in a matter of months, as a court has annulled the results of the country's May election and ordered another one be held.
Alexander Van der Bellen was elected the nation's first left-wing president since World War II in the May vote, defeating right-wing candidate Norbert Hofer in a tightly fought contest decided by mail-in votes.
Hofer's Freedom Party brought the case to court, claiming that some of the postal votes in various districts had been carried out illegally. The court found there had been some irregularities and ordered the run-off vote be repeated "completely and throughout Austria," according to a court statement.
No date has been set for the re-vote. Incumbent Preisdent Heinz Fischer's term ends July 8. Until the new president is elected, the top three leaders of the National Assembly will serve as president. Hofer will be part of that group since he represents the third-largest party in parliament.
If elected, Hofer would become the European Union's first far-right head of state. His party has risen on a populist groundswell sweeping the continent caused by the European Union's failure to make progress in the ongoing economic and migrant crises.
A possible Hofer victory was seen as fuel for other far-right parties across the continent, such as France's National Front, the Danish People's Party and Germany's AFD.
Van der Bellen, a 72-year-old economist, ran as an independent, although the Green Party which he formerly led financially backed his campaign.
Van der Bellen won 50.3% of the ballot (2,254,484 votes) to Hofer's 49.7% (2,223,458 votes), the Austrian Interior Ministry announced after the poll.
The court said that the number of votes considered irregular was high enough to have affected the outcome of the vote.
Europe's migrant crisis featured heavily in the campaign period. While Hofer's Freedom Party stood strongly against migration, Van der Bellen -- whose parents spent time in a refugee camp before settling in Austria -- championed liberal migration policies.
Austria followed Germany in opening its doors to thousands of refugees who had been trapped in their attempts to transit through Hungary, a country widely criticized for its hard-line stance in defending its borders.