Scores of asylum-seeker families, including babies born in Australia, face the prospect of deportation to Nauru after a High Court ruling.
The full bench of the court on Wednesday rejected a legal challenge to the federal government's offshore immigration detention regime.
It did so after considering the case of a pregnant Bangladeshi asylum seeker who was brought to Australia from Nauru for treatment for serious health complications.
She faced the prospect of being returned to the Pacific island with her one-year-old child.
In a majority decision the court said the woman's detention on Nauru was not unlawful.
It also ruled the commonwealth's role in her detention was authorised under Australian migration laws, and the government's offshore processing deal with Nauru was valid under the constitution.
"The High Court held, by majority, that the plaintiff was not entitled to the declaration sought. The conduct of the Commonwealth in signing the second MOU with Nauru was authorised by s 61 of the Constitution," the judgment said.
"The Court further held that the conduct of the Commonwealth in giving effect to the second MOU (including by entry into the Administrative Arrangements and the Transfield Contract) was authorised by s 198AHA of the Act, which is a valid law of the Commonwealth."
Concern for fate of 267 asylum seekers
The ruling has implications for 267 other people - including 91 children - who are in Australia for medical treatment.
Of the 54 children, 36 are attending Australian schools.
The federal government is now under pressure to show compassion towards the group.
Human rights lawyer Claire Hammerton from the advocacy group for child refugees the concern is now for 90 children set to be returned to Nauru.
“ChilOut is extremely worried about these children and their families, and in particular the 37 babies who were born in Australia, who will be deliberately sent to a place the Australian Government knows is unsafe for children,” she said.
PM: 'The line has to be drawn somewhere'
Save the Children, which has had a child protection role on Nauru, called on Prime Minister Malcolm Turnbull to show sympathy towards the 37 babies and children.
But the government is wary about the message being sent to people smugglers.
Immigration Minister Peter Dutton was concerned smugglers were channelling a message to potential customers that "Dutton's a soft touch and you can put women and children on boats and be successful".
Mr Turnbull issued a strong defence of the coalition's border protection policies, insisting people smugglers would not prevail over Australia's sovereignty.
"The line has to be drawn somewhere and it is drawn at our border," he told parliament.
The opposition wants a third country resettlement option to resolve the asylum seekers' fate.
It was not ruling out reviving the Gillard government's people-swap deal with Malaysia that was quashed by the High Court in 2011.
"We would be talking to all of our neighbours to ensure we have a regional approach," deputy Labor leader Tanya Plibersek said.
Australian Greens senator Sarah Hanson-Young said the prime minister would be authorising child abuse if the families were sent back to Nauru.
"Sending them back would be torture," she said.
The coalition, with Labor's support, retrospectively changed laws to bolster the commonwealth's ability to pay for the offshore facilities last year.
Its case in part hinged on a sudden decision last October by the Nauru government to allow asylum seekers to roam around the island nation at will.