Labor representatives said it was about "doing the right thing", and the vote provoked cheers from asylum-seeker activists in parliament's public gallery.
According to the bill, a medical panel of two doctors would assess requests for medical transfers of people on Manus Island and Nauru.
If approved, the person will be brought to the detention camp on Christmas Island, which is an Australian territory closer to Indonesia than the mainland, for treatment.
Sick asylum seekers often have to fight the Australian government in court for permission to be transferred to an Australian hospital.
Prime Minister Scott Morrison says the detention center in Christmas Island is aimed " both to deal with the prospect of arrivals as well as dealing with the prospect of transfers".
The government lost a series of votes by 74-75 after the Labor party joined forces with Greens and the majority of the crossbench on Tuesday to pass amendments that give doctors a greater say on medical evacuations. "He has led this process to weaken and compromise our borders".
Mr Morrison denied his trumped-up rhetoric played into the hands of people smugglers.
"The priority for me having met with the general of Operation Sovereign Borders is to deal with the hard circumstance that Bill Shorten created", Dutton told Australian Broadcasting Corporation (ABC) television.
In 2001, Australia's then conservative Prime Minister John Howard refused permission for a Norwegian ship carrying 433 rescued refugees to enter Australian waters. The Christmas Island center has been described as a high-security prison where the unlucky "boaters" are forced to cohabitate with hardened criminals, including rapists. But 17 Vietnamese asylum seekers who reached northeast Australia in August last year - the first boat arrival in four years - were sent to Christmas Island before they were returned to their homeland.
The man was arrested after police were called and transferred to Villawood detention centre.
The secretary will have to refer the case to the Immigration Minister, who will have 72 hours to either approve or reject a transfer. As of December, 380 boat people were in detention and 15,674 in the community.
"Our government is running border protection in this country".
"I'm going to be engaged in very clear and direct messaging to anyone who thinks they should get on a boat", Mr Morrison said. "People have died as a result", Ms Nicholls said.
"The narrative of the past six years has been one of crushing any hope", he said.
David Crowe is Chief Political Correspondent of the Sydney Morning Herald and The Age.