Crossbench senator Derryn Hinch wavered before delivering his crucial support for a bill enabling faster medical transfers for refugees on Manus Island and Nauru.
The controversial changes passed the Senate 36 votes to 34 on Wednesday, in a humiliating defeat for the coalition government a day after suffering a historic loss in the lower house.
Senator Hinch said he was swayed by an amendment limiting medical transfers to asylum seekers already on Manus Island and Nauru.
"This is the toughest decision I've had to make since I came into this chamber," he told parliament.
The Justice Party founder admitted lingering doubts about the bill, but supported its passage after being briefed by security forces and both sides of parliament.
"It has been a very tortured 24 hours," Senator Hinch said.
Under the changes, two doctors can recommend medical evacuations for sick asylum seekers on Manus Island and Nauru.
The home affairs minister will have 72 hours to make a decision on whether to grant the transfer, with the extended deadline important in winning Senator Hinch over.
His support, along with South Australian independent Tim Storer and Centre Alliance's two senators, secured the passage of the Labor and Greens-supported bill.
Independent lower house MPs Kerryn Phelps and Julia Banks, both key supporters of medical transfers for refugees, were in the Senate chamber to witness the final vote.
They embraced Greens, crossbench and Labor senators after the parliamentary victory, which sparked a smattering of applause on the floor of parliament from the bill's backers.
With the refugee transfer measures set to pass, Prime Minister Scott Morrison announced the government would reopen the Christmas Island immigration detention centre.
He also vowed to toughen up Operation Sovereign Borders.
Government Senate leader Mathias Cormann said the refugee transfer legislation would compromise Australia's border protection regime and national security.
"As a result of Bill Shorten's bill, rapists, murderers and pedophiles will still get a free pass into this country. Bill Shorten should be ashamed of himself," he told senators.
Labor Senate leader Penny Wong launched a fiery attack on the government, accusing the coalition of "shameful" leaking of an intelligence briefing which warned against the bill.
"There are lies being told about this bill by those opposite and they are doing it because they are desperate," she said.
"Rather than running these lies, why don't you just call an election?"