The tennis star and his family have welcomed the judge's decision, but the government is considering overruling the move which could still see him deported.
A court in Australia has ordered that Novak Djokovic be released from immigration detention after quashing his visa cancellation by the authorities over his vaccination status.
Monday's decision opens the door for the tennis star to play in next week's Australian Open, however the government is wrangling over whether to intervene and reimpose the visa ban.
The 34-year-old Serb — who has confirmed that he is not vaccinated against COVID-19 — has been fighting deportation to defend his title in Melbourne and win a record 21st Grand Slam title.
But while Djokovic's supporters and the Serbian press have been celebrating, much uncertainty still surrounds the case. The judge's decision — based on procedural errors — does not yet mean for sure that the world's top-ranked player will be free to compete.
His fate in the matter has now become caught up in a web of politics and public health policy amid the pandemic, while the world looks on.
The player himself has welcomed the judge's decision via social media. "Despite all that has happened, I want to stay and try to compete," he tweeted, thanking supporters for "standing with me" and "encouraging me to stay strong".
Family welcome court decision
Members of Djokovic's family also welcomed the court decision as "bigger than any of his Grand Slam victories", as they criticised once more his prior treatment by the Australian authorities.
Shortly after his release, Djokovic took to the tennis court to train for next week's tournament, they told a news conference organised by the family in Belgrade.
"Novak is free, a little while ago he was training on the court," his brother Djordje said. "He went to Australia to play tennis, to participate in a new Australian Open and set a new record."
Residents and newspapers in Serbia celebrated the court reprieve. Djokovic "has won in Australia", triumphed the daily Blic, while Vecernje Novosti said the champion "has beaten Australia", while reminding readers that "nothing is finalised".
Earlier, amid further confusion after the decision, the government denied reports that Djokovic had been arrested again.
Supporters of the tennis champion crowded around a car that was seen leaving his lawyer's office in Melbourne. In chaotic scenes, police trying to disperse the crowd appeared to use pepper spray against the gathered fans.
Watch: Djokovic supporters celebrate visa decision
Visa cancellation 'seriously illogical'
In Monday's hearing, Circuit Court Judge Anthony Kelly ordered the government to release Djokovic from Melbourne hotel quarantine within 30 minutes of his decision. The player's lawyers had alleged procedural irregularities.
But government lawyer Christopher Tran told the judge after the ruling that the immigration minister Alex Hawke “will consider whether to exercise a personal power of cancellation.”
That would mean mean Djokovic could again face deportation and could miss the Australian Open.
To enter Australia, travellers must be fully vaccinated against COVID-19 or have an exemption with a genuine medical reason.
Judge Kelly questioned the decision to deny entry to Djokovic, noting that the player had provided officials at Melbourne’s airport with a medical exemption given him by Tennis Australia — which is organising the tournament — and two medical panels.
“The point I’m somewhat agitated about is what more could this man have done?” Kelly asked Djokovic’s lawyer Nick Wood.
The player's legal team submitted 11 grounds for appeal against his visa cancellation, describing it as “seriously illogical,” irrational and legally unreasonable.
Transcripts of Djokovic's interview with Border Force officials and his own affidavit revealed that he claimed "he had done absolutely everything that he understood was required in order for him to enter Australia,” Wood said.
On being told by government lawyers that it may intervene again, Judge Kelly said the threat of a further visa cancellation meant the “stakes have now risen rather than receded.”
“If this man is to be summarily removed upon a personal exercise of cancellation power, he cannot return to this country for three years, am I right about that?” Kelly asked the government lawyers.
The lawyers confirmed that would be the case if Djokovic's visa is cancelled again, although it has been suggested that the government could lift such a ban.
Djokovic's visa was cancelled shortly after he arrived in Melbourne late on Wednesday because officials decided he didn’t meet the criteria for an exemption. Court documents released include a transcript of his interview with border officials.
The player argued he did not need proof of vaccination because he had evidence that he had been infected with the coronavirus last month and had been granted an exemption.
Australian medical authorities have ruled that a temporary exemption for the vaccination rule can be provided to people who have been infected with COVID-19 within six months.
But the Australian Border Force declined to allow Djokovic an exemption from national vaccination rules for incoming non-citizens, saying an infection in the previous six months was only a ground for a vaccine exemption in cases in which the coronavirus caused severe illness.
The player's lawyers said Djokovic's first positive COVID-19 PCR test was on December 16. But photos posted on social media appear to show him at an event in Belgrade with young Serbian tennis players the following day.
When questioned about the matter in Belgrade, Djokovic's brother abruptly brought the news conference to a close.
The tennis star's anti-vaccination stance has been castigated as a bad example, given Serbia's low vaccination rate. According to figures from Our World in Data, less than 50% of the population has received two doses, with only a quarter having had a third booster jab.
Nadal criticises 'circus'
The five-day saga has made headlines worldwide, with the confusion over Djokovic's status an embarrassment for the Australian authorities.
People have been outraged by the initial apparently favourable treatment shown to the star in giving him an exemption, as unvaccinated Australians face tough travel and quarantine restrictions.
But there has also been anger at his subsequent confinement in a detention hotel, which has focussed attention on the treatment of asylum seekers in Australia. The player had been under guard in Melbourne since Thursday, when his visa was cancelled.
The virtual hearing crashed several times because of an overwhelming number of people from around the world trying to watch the proceedings.
Djokovic is a nine-time Australian Open champion. His 20 Grand Slam singles titles are a men’s record he shares with Roger Federer and Rafael Nadal.
On Monday Nadal called the vaccination controversy in Melbourne a "circus", adding that the decision to allow Djokovic to play in the tournament was "the fairest decision".
However, the Spaniard once again defended vaccination. "The most important institutions in the world say that the vaccine is the way to stop this pandemic and the disaster that we have been living for the last 20 months", he told Spanish radio Onda Cero.