The High Court has reaffirmed the federal government's ability to detain people brought to Australia for medical treatment from the Nauru or Manus Island detention centres.
The case involved an Iranian mother and daughter brought to Australia in 2014 for health care.
The pair had arrived on Christmas Island in 2013 before being sent to Nauru.
While in Australia for treatment, they were detained in Darwin and Melbourne at immigration transit accommodation.
The court ruled on Wednesday their detention had been lawful.
Late last year, they were released into the community and must observe a curfew and strict conditions.
Victoria Legal Aid spokesman Dan Nicholson said the government has unique and special powers which can have a serious and detrimental impact on a highly vulnerable and traumatised group of people.
He said the decision was disappointing but it was important to test and clarify the legality of these powers.
"The decision today gives a clear indication that for the other 250 asylum seekers and refugees currently in Australia for reasons like medical treatment, a decision by the Commonwealth government to send them back to an offshore processing centre could likely be disputed in the courts," he said.