This is the first time in decades a government has lost a vote on its own legislation in the lower house.
The move is a blow for PM Scott Morrison's minority government's highly controversial immigration policy.
Since 2013, Australia has sent asylum seekers arriving by boat to detention centres on Nauru and Papua New Guinea.
Critics say it has harmed the welfare of detainees, including children.
Doctors have long warned of inadequate medical facilities on the islands, while the UN has previously described the camp conditions as "inhumane".
However, Mr Morrison said: "There is no form of this bill that does not weaken our border protection."
Australia has long defended its offshore detention policy by arguing that it stops deaths at sea and disrupts the trade of people smuggling.