More than 260 asylum seekers face being deported from Australia to Nauru after Australia's highest court rejected a challenge to the legality of the government's refugee policy.

A Bangladeshi woman, who cannot be named, had gone to the High Court to challenge the legality of Australia paying the tiny Pacific nation to detain asylum seekers who attempt to reach Australian shores by boat.

The woman had been sent to Nauru in January 2014 but was brought back to Australia in August 2014 because for medical help due to pregnancy complications.

She had a child and then gained a court injunction preventing her return to Nauru pending her court challenge.

A total of 267 asylum seekers, most of whom came to Australia for medical treatment or to support a family member who needed treatment, have gained injunctions preventing their return to Nauru until the case was settled.

But a majority of the seven judges ruled the agreement in operation between the two countries since August 2013 was legal.

The government's policy is never to resettle in Australia any refugee who attempts to reach the country by boat.

The parliament passed retroactive laws last year to firm up the legal basis of the Nauru deal.

Refugee and rights advocates have appealed to the government to let the 267, including 91 children, stay.

"The legality is one thing, the morality is another," said Daniel Webb, director of legal advocacy at the Human Rights Law Centre, which handled the case against the government.

"It is fundamentally wrong to condemn these people to a life in limbo on a tiny island. The stroke of a pen is all that it would take our prime minister or our immigration minister to do the decent thing and let these families stay.

Mr Webb said the plaintiff was reduced to tears when told she had lost the case.

"My hope is that common decency and basic compassion prevails and that these babies and their families have an opportunity at life somewhere safe," he said.

Immigration minister Peter Dutton said before the ruling that the government acted in the best interests of asylum seekers brought to Australia from Nauru for medical treatment.

"We're not going to send people into harm's way," he told Sky News television.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.