The parliament has voted in favour of changes that make it easier for refugees on Manus Island and Nauru to travel to Australia for medical treatment, handing a historic defeat to the Morrison government in the process.
The refugee medevac bill passed the Senate on Wednesday morning, with a coalition of Labor, Greens, Centre Alliance and crossbench senators voting in favour.
It passed the house on a knife edge on Tuesday evening – 75 ayes to 74 noes – after the Labor and crossbencher coalition voted to ignore constitutional concerns raised by the government and debate the bill regardless.
The lower house vote constituted a defeat on a piece of substantive legislation for the government, which is extremely rare.
The government stridently opposed the changes, claiming it would lead a flood of people smuggler boats making a dangerous sea voyage to Australia. Attorney-general Christian Porter also launched a bid to stop the legislation on the grounds it was unconstitutional.
But the opposition, Greens and key crossbenchers such as Wentworth MP Kerryn Phelps and senator Tim Storer argued it was both a necessary and humane change.
The makeshift coalition stared down the border security rhetoric and constitutional concerns to see the bill pass the house and go back to the Senate for final approval in the space of 24 hours.
Under the new law, two doctors can determine if it is necessary for a refugee or asylum seeker to be transferred to Australia for medical treatment.
If the minister for immigration disagrees with the transfer on health grounds, the case can go to a body of medical professionals who would then have the final say. The minister could also veto the transfer on national security grounds, or if the detainee has a history of "serious criminality".
It will only apply to refugees and asylum seekers currently on Nauru and Manus.
There was some uncertainty on Wednesday morning as to whether senator Derryn Hinch, who ended up voting in favour, would support the legislation.
He told the Senate it was "the toughest decision I have had to make" and said that he had been swayed by the amendment that it only apples to people now on Manus Island and Nauru.
"That it is a sort of reverse grandfather. It stops there. It's not an encouragement, I believe, to ... people smugglers, who are despicable and should be despised, because it will only apply to people who are there," he said.