The coalition government's religious discrimination laws have passed their first legislative hurdle, after Labor agreed to back them in the lower house while securing changes.
The religious discrimination bill passed in the early hours of Thursday morning by 90-6 following a mammoth debate in the House of Representatives which included objections from Liberal moderates and independent MPs as they sought amendments.
But in a blow to the government, the opposition and crossbench was successful in amending a controversial clause of the Sex Discrimination Act allowing religious schools to discriminate on grounds including sexuality and gender identity.
The amendments will prohibit vilification of and discrimination against children based on sexuality and gender identity.
Liberal MPs Trent Zimmerman, Bridget Archer, Fiona Martin, Katie Allen and Dave Sharma voted against the government to amend the bill, with the vote landing 65-59.
Mr Zimmerman had earlier said he would not stand by and make life for transgender people more difficult.
Labor leader Anthony Albanese vowed his party will insist on its amendments to the religious discrimination bill in the Senate.
Proposed opposition amendments clarified a key pillar of the laws - a "statement of belief" clause designed by the government to shield people expressing religious beliefs even if they're offensive - did not override existing discrimination protections.
The government did not agree to any of Labor's proposed amendments.
"We support people's right to practise their faith free from discrimination," Mr Albanese said.
"But this should not remove protections that already exist to protect against other forms of discrimination."
Prime Minister Scott Morrison said he had "earnestly hoped" the bill would unite the parliament.
"Let me be very clear tonight - with the bill and the position taken by the government - that we reach out with nothing other than love, care, compassion and support to every child regardless of their sexual orientation or their gender identity," he said.
The government made some small amendments which Labor agreed to, including that - other than the statement of belief clause - the bill will not override existing laws.
Mr Zimmerman and Ms Archer voted with Labor because the government would not agree to amend the bill to clarify the statement of belief clause.
With the statement of belief amendment vote tied at 62-62, Speaker Andrew Wallace's intervention meant the vote was lost.
Ms Archer also voted with Labor after the government did not amend the bill to outlaw vilification of people of faith.
Labor frontbencher Tony Burke questioned what the debate had been about if the government did not want legal protection against people being harassed, intimidated, threatened or vilified because of their faith.
He said the bill - without the amendment to prohibit vilification - did not match what the prime minister had said it was about.
Communications Minister Paul Fletcher said the government does not condone vilification or hate speech but Labor's anti-vilification proposal was "complex" and required careful consideration to balance competing rights.
He said the proposed provisions would create further inconsistencies and confusion between Commonwealth, state and territory laws.
The coalition partyroom earlier this week agreed to amendments to add a clause to the Sex Discrimination Act prohibiting the expulsion of students because of their sexuality.
But it refused to extend the same protections to transgender children.
Liberal MP Angie Bell, who previously had problems with the bill, backed the legislation in the end because it represented a "net gain for gay rights".