MPs stayed overnight to debate the bill’s progress, with five government backbenchers eventually crossing the floor.
The central issue was that the bill did not protect transgender children from being expelled from religious schools.
Backbench MPs crossing the floor meant the amendment was dropped from 65 to 57.
This led to the government voting against its own bill, but it lost and the bill will now go to the Senate.
Opposition Leader Anthony Albanese said the debate was “very constructive” – for the most part.
“I support making sure people can’t be discriminated against because of their religion or faith,” he told Today.
“But I do not support discrimination against other people under this legislation.”
Mr Albanese said Labor believed further amendments to the Bill were needed, after it passed with the added protections for transgender students.
“There are other issues of discrimination against older people receiving home care, the bill covers older residents but it doesn’t cover home care,” he said.
He said Labor would pursue further amendments in the Senate.
But Tasmanian Senator Jacqui Lambie has signaled that the government’s Religious Discrimination Bill could face new hurdles in the Upper House.
“I won’t vote for that,” she told Today.
“We have golden legislation that we have in Tasmania.
“It works very, very well and I remind the Liberal and Labor parties that your people there, the people in your state voted to include it.”
The law already includes expulsion protections for gay students.
Prime Minister Scott Morrison won majority support from the Coalition earlier in the week, although several MPs voiced their opposition.
Labor MP Stephen Jones also gave a personal and moving speech opposing it.
In it, Mr Jones mourned his gay nephew, who recently took his own life, and hailed his gender-nonconforming son’s bravery.
“He’s got more courage than any other boy his age I’ve ever met,” Mr Jones said.
In pictures: Sydney celebrates ‘yes’ triumph with jubilant street party
The Religious Discrimination Act would seek to make it illegal to discriminate against someone because of their religious beliefs, with changes to the Sex Discrimination Act to prohibit the expulsion of students for being gay.
Labor has said it supports religious freedom, but additional protections need to be put in place.
Federal Attorney General Michaelia Cash argued that an exemption for trans students would create problems for single-sex religious schools.