The lawyers would not disclose which city the boy was in or any further details, citing privacy concerns.
The boy and his mother have been found to be genuine refugees by the government of Nauru and were living in an Australian-funded camp on the island.
The boy had already tried to kill himself three times, the court found.
Lawyers for the Home Affairs department and minister Peter Dutton argued there were adequate health care options on the island.
But the judge concluded the boy was suffering from a “serious mental illness” and could not be “adequately treated... or really treated at all” on Nauru since the departure of Dr Vernon Reynolds, a child psychiatrist who was working on the island on behalf of private healthcare provider IHMS, contracted by the Australian government.
Dr Reynolds’ own report to the court recommended the transfer, saying medical staff on Nauru did “not have the ability” to provide the specialist care needed.
The boy also suffers from a long-running physical health problem that requires surgery.
Lawyers for Mr Dutton said the surgery could be completed on Nauru, but the judge rejected that argument.
“Although the hospital at Nauru is said to be able to fix that problem two of its patients died as a result of the actions of the anaesthetist on the island who was then arrested,” the judge wrote in his judgement.
The boy’s father suffered a brain injury from a “serious” bicycle accident was himself transferred to Australia for specialist treatment. He remains in a Brisbane immigration centre.
The Iranian family fled Iran in 2013 and arrived in Australia on a boat. They were initially taken to Christmas Island before the mother and son were sent to Nauru.
Justice Perram conceded the transfer to Australia would cause a “considerable, and most likely irrecoverable” cost to the government.
“Given that a life is at stake, however, I do not regard this as the important factor it would usually be. I do not, however, disregard it altogether,” the judge said.
“I regard the risk of the boy’s death as being a most powerful and compelling consideration.”
He approved an injunction demanding the immediate transfer.
“I note the next plane out of Nauru is on Wednesday 7 March 2018. To be quite clear, the boy and his mother should be on that plane.”
Readers seeking support and information about suicide prevention can contact Lifeline on 13 11 14