• Judge Anthony Kelly abruptly ended days of legal wrangling, after the state dropped its decision to revoke the star's visa.
• But a government lawyer warned that Australia may yet use ministerial powers to order Djokovic's removal from the country.
World tennis number one Novak Djokovic won a shock victory in his bid to remain in Australia Monday, with a judge ordering his immediate release from immigration detention.
Judge Anthony Kelly abruptly ended days of legal wrangling, after the state dropped its decision to revoke the star's visa.
But a government lawyer warned that Australia may yet use ministerial powers to order Djokovic's removal from the country, which would result in him being banned for three years.
With the Australian government facing a humiliating and high profile defeat, lawyer Christopher Tran informed the judge that immigration minister Alex Hawke may step in with executive powers.
"I'm instructed (the minister) will consider whether to exercise a personal power of cancellation," he said.
Djokovic has been in detention at 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, recalled that Djokovic was interviewed overnight at Melbourne airport after his arrival late on Wednesday night.
In the early hours of the next morning, the player 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.
If Djokovic had 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.
Though the hearing was held online, a small group of Djokovic fans gathered outside the federal court building, waving a Serbian flag, holding up a photo of their hero and dancing to the tune of an accordion.
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."
Prime Minister Ana Brnabic said this weekend that after "constructive talks" with her Australian counterpart "we managed that he gets gluten-free food, exercise equipment, a laptop."
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.