MPs stayed all night to debate the bill’s progress, with five government backbenchers ultimately crossing the floor.
The central issue was over the bill not protecting transgender children from being expelled from religious schools.
The backbenchers crossing the floor meant that amendment passed 65 to 57.
The bill will now be sent to the Senate.
The legislation does include protections against expulsion for gay school students.
Prime Minister Scott Morrison secured majority Coalition support for it earlier in the week, though several MPs voiced their opposition.
Labor MP Stephen Jones also delivered a personal and moving speech that spoke against it.
In it, Mr Jones mourned his gay nephew, who took his own life recently, and hailed the bravery of his gender non-conforming son.
“He has more courage than any other boy of his age that I’ve ever, ever met,” Mr Jones said.
The Religious Discrimination Act would seek to make it illegal to discriminate against someone based on their religious beliefs, with changes to the Sex Discrimination Act to prohibit expelling students for being gay.
Labor has said it supports religious freedom, but that extra protections need to be in place.
Federal Attorney-General Michaelia Cash has argued an exemption for trans students would create problems for religious single-sex schools.