Tennis world No.1 Novak Djokovic has been freed from immigration detention after the government conceded the cancellation of his visa was unreasonable.
But Immigration Minister Alex Hawke still has a personal power to remove Djokovic from Australia.
Federal Court Judge Anthony Kelly ordered on Monday afternoon that the original decision to cancel his visa should be quashed and he be paid costs.
The order was made after lawyers for Home Affairs Minister Karen Andrews conceded the decision to proceed with an early morning airport interview and cancel his visa last week was unreasonable in the circumstances.
Djokovic was told at 5.20am on Thursday that he had until 8.30am to respond to a notice of intention to cancel his visa. His comments were sought instead at 6.14am.
The decision to cancel his visa was made just over an hour later.
Judge Kelly said if Djokovic had been given until 8.30am he could have consulted others about the decision.
He ordered that Djokovic must be released within 30 minutes of the order being made and that his passport and other personal effects be returned immediately.
The controversy began following Djokovic's arrival in Australia late on Wednesday, after he declared he had a medical reason not to get vaccinated against COVID-19.
He told an immigration interviewer he had not been vaccinated and had contracted COVID-19 twice - in June 2020 and December 2021.
Djokovic handed over the exemption documents from Tennis Australia before being told about the notice of intention to cancel his visa just before 4am on Thursday.
"I arrived here because of these documents otherwise I wouldn't have been allowed to come in," he said, according to transcripts released by Judge Kelly.
"I mean you kind of put me in a very awkward position where at four in the morning I can't call director of Tennis Australia, I can't engage with anybody from the Victorian state government through Tennis Australia. I just, you put me in a very uncomfortable position."
The tennis star's legal challenge was plagued by technical issues on Monday, with a live stream collapsing under the pressure of tens of thousands of people trying to watch.
He was allowed out of detention to be with his lawyers for the hearing.
Christopher Tran, representing the government, said Immigration Minister Alex Hawke will now consider whether to exercise a personal power of cancellation over Djokovic's visa.
Judge Kelly said he would have been "something approaching incandescent" had he heard about that after the hearing, foreshadowing potential further legal action.
He said it was unlikely any other judge could get up to speed with the case, and pointed out that Djokovic's personal and professional reputation and economic interests may be directly affected.
"If this man is to be summarily removed upon the personal exercise of cancellation power, he cannot return to this country for three years," he said.
"I expect to be fully informed in advance if I am required to continue to be available for any further proceeding that is to be sought, because on a view, the stakes have now risen rather than receded."
Earlier Nick Wood SC said Djokovic declared before boarding his flight to Australia from Dubai that he had a medical contraindication for vaccination and was able to provide evidence - a medical exemption by Tennis Australia.
Judge Kelly asked: "What more could this man have done?"
"Here, a professor and an eminently qualified physician have produced and provided to the applicant a medical exemption," he said.
"Further to that, that medical exemption and the basis on which it was given, was separately given by a further independent expert specialist panel established by the Victorian state government."
Comment has been sought from both ministers.
Australian Associated Press