World number one Novak Djokovic won a stunning victory Monday over the Australian government, overturning the cancellation of his visa on COVID-19 health grounds, and ending his detention.
It was an extraordinary setback for the government, which has imposed strict restrictions on its borders for the past two years to stop the spread of the coronavirus.
In an emergency online court hearing, the judge ordered that the decision to cancel Djokovic's visa "be quashed".
The judge ordered that the unvaccinated tennis superstar "be released immediately and forthwith from immigration detention".
"Such release must occur no later than 30 minutes after the making of this order," he added.
Australian taxpayers will be asked to pay costs for Djokovic's high-powered legal team.
"Novak, Novak, Novak," chanted dozens of fans of the nine-time Australian Open champion as they marched in celebration, drums banging, outside Melbourne's federal courthouse.
The 34-year-old Djokovic had arrived in Melbourne last Wednesday ahead of the Australian Open, which starts in just one week, hoping to win a record-breaking 21st Grand Slam title.
But even as he savours an extraordinary win in the federal court, his tournament dream may yet be out of reach.
The government's lawyer told the court that Immigration Minister Alex Hawke may decide to use his "personal power of cancellation" despite the player's legal victory.
After touching down in Australia, Djokovic was taken into an overnight interview with border agents, who decided the champion had failed to present a solid medical reason for not being jabbed.
Djokovic's visa was revoked and he was moved to a notorious immigration detention facility pending deportation.
He spent four nights in the former Park Hotel, a five-storey facility that holds about 32 migrants trapped in Australia's hardline immigration system -- some for years on end.
An early plea by Djokovic to be moved to a facility where he can train for the Australian Open had fallen on deaf ears, his lawyers said.
'Not human conditions'
The court's finding, read out in an online hearing, said the player was not given the chance to reply fully before his visa was torn up.
In the early hours of Thursday, Djokovic was told he had until 8:30 am to reply to the proposed cancellation of his visa. But instead, the border agent cancelled it at 7:42 am.
Had Djokovic been given until 8:30 am as first promised, "he could have consulted others and made submissions to the delegate about why his visa should not be cancelled," the judge said.
According to a transcript of the airport interview, Djokovic told the border control agent: "I just really don't understand what is the reason you don't allow me to enter your country."
Earlier, at a rally in Belgrade, Djokovic's mother Dijana claimed her son was staying "in not human conditions" during his four-night stay at the detention centre.
"They detained him and even don't give him breakfast, he has only lunch and dinner," she said, quoted by local media.
"He does not have a normal window, he stares at a wall."
Though it had no bearing on his court case, Djokovic's claim of a positive test on December 16 stirred controversy after it emerged he had attended a gathering that day for the Serbian national postal service launching a stamp series in his honour.
Pictures shared by the Belgrade tennis federation also showed him at a young players' event in the city on December 17.
It reported that he had handed over cups and prizes to players. No one was wearing a mask.
Another tennis player -- Czech doubles specialist Renata Voracova -- has also had her visa cancelled after obtaining a medical exemption.
She flew out of Australia on Saturday after being held in the same Melbourne centre as Djokovic.