Austria's presidential runoff election must be held again, the Constitutional Court ruled on Friday, handing the Freedom Party's narrowly defeated candidate another chance to become the first far-right head of state in the European Union.
The verdict comes a week after Britain delighted anti-EU groups including the Freedom Party (FPO) by voting to leave the bloc.
Concerns about immigration and jobs featured prominently in that referendum, as they did in Austria's knife-edge election.
Norbert Hofer of the anti-immigration FPO lost the May 22 vote to former Greens leader Alexander Van der Bellen by less than one percentage point, or around 31,000 votes in the race for what is largely a ceremonial position.
The court found more than twice that number of postal ballots had been affected by breaches of the electoral code.
"It is absolutely clear to the Constitutional Court that laws governing an election must be applied rigorously," the court's 14 judges said in their ruling on a challenge brought by FPO leader Heinz-Christian Strache.
The re-run will reopen a debate that split Austria almost evenly, pitting town against country, and blue-collar workers worried about immigration and falling living standards against the more highly educated.
Witnesses told the court of various irregularities in the way postal ballots were counted.
These included ballots being processed before the officially ordered start the morning after the election, and counts being carried out in the absence of party observers, often because officials were racing to provide a result quickly.
The court found no proof that the result had been manipulated but the possibility that the outcome might have been affected is enough for a challenge to succeed.
The irregularities that have come to light have dismayed the Austrian public.
"There was sloppiness," Austrian Interior Minister Wolfgang Sobotka, whose ministry oversees elections and was accused by several witnesses of applying pressure on officials to provide a rapid count, told reporters after the verdict.
The government must now choose a date for the election.
How the outcome might change in a European political climate overshadowed by the Brexit vote is unclear - the referendum could buoy populist sentiment or have a chilling effect on it.