Australia has controversially repealed a law which allowed sick refugees held offshore to be treated in the country.
The government's push to scrap the "medevac" law - passed by opposition MPs in February - has drawn criticism as cruel and inhumane.
But Prime Minister Scott Morrison argued the law had presented a "national security" risk.
At least 12 people have died under Australia's offshore detention policy.
Since 2013, the nation has sent asylum seekers arriving by boat to detention centres on Nauru and Papua New Guinea (PNG).
Canberra has defended the controversial policy by arguing that it stops deaths at sea and disrupts human trafficking.
What was 'medevac' about?
It followed public outrage about the health crisis of detainees - including children - on the islands of Nauru and Manus Island (PNG). There were reports that children as young as 11 were attempting suicide.
That led to the passage of the medevac bill - the first time in decades that a government had lost a vote on its own legislation in the lower house.
Experts have repeatedly warned of inadequate medical facilities on the islands, while the UN has previously described the camp conditions as "inhumane".
The medevac law allowed for doctors to evacuate ill people to Australia for urgent medical treatment.
The government said as a result of the medevac law, 135 refugees were brought to the mainland for treatment this year.
It argued the law had been a "border protection" risk and was a "loophole" for refugee advocates to bring asylum seekers into Australia.
"[The] weak and bad medevac laws must be repealed in order to strengthen our national security again," said the government's Senate leader, Mathias Cormann.
In opposing the repeal, opposition MPs said the government was "devoid of a heart".
"This will deny sick people treatment. It will deny sick people the opportunity to see a doctor," said Labor Senator Kristina Keneally.
Opinion polls had shown that 62% of voters supported the law.
How did the government succeed this time?
It secured the support of a key independent lawmaker, Jacqui Lambie, to get the numbers in the Senate on Wednesday.
Ms Lambie argued the law "was not a national security threat", but said it gave too much discretion to doctors.
Opposition senators accused the government of "secrecy" in striking the last-minute deal.
"Members of the cabinet of Australia are coming in to vote on a deal they haven't even seen," said Penny Wong, the Labor opposition's Senate leader.
A Greens senator, Nick McKim, said the vote was "a dark day for the majority of Australians who support the medevac legislation".