Australia's first legal same-sex marriages will go ahead in January after a marathon session of parliament passed laws.
"What a day! What a day for love, for equality, for respect. Australia has done it," Prime Minister Malcolm Turnbull told parliament, just before the bill passed.
From this Saturday same-sex couples will be able to lodge a notice of intended marriage, to start the minimum notice period required before getting married from January 9.
Only four MPs in the House of Representatives voted against a private bill on Thursday, a week after the legislation was agreed to by the Senate.
The laws went through unchanged after 56 hours of debate, despite a push from conservative politicians for additional exemptions, including for religious organisations, civil celebrants and Defence chaplains.
A packed public gallery applauded and burst into the song "I am Australian".
Long-time campaigner Shelley Argent, the national spokeswoman for Parents and Friends of Lesbians and Gays, said she lobbied for the bill because of her love for her gay son, James.
"I don't care if he ever gets married - I just wanted him to have the right," she said.
Labor leader Bill Shorten said the new law spoke for a modern Australia, "inclusive and fair".
"We are no longer a nation of people who voted no, or people who voted yes - we are simply Australians, one and all," he said.
Greens leader Richard Di Natale, who was wearing striped rainbow shoes, described the vote as a great moment.
"In what has been a bleak year for Australian politics, we saw a rainbow poking through," he told AAP.
Under the new laws, ministers of religion and religious marriage celebrants will be able to act in accordance with their beliefs about marriage.
Religious bodies will be able to act in accordance with their doctrines, tenets and beliefs in providing facilities, goods and services in connection with marriage.
Both major parties had given their members a free vote on the issue.
More than 120 MPs spoke on the bill, which was sponsored by gay Liberal senator Dean Smith and backed by colleagues Warren Entsch, Trent Zimmerman, Tim Wilson and Trevor Evans.
Former prime minister Tony Abbott, Treasurer Scott Morrison, junior ministers Michael Sukkar and Alex Hawke, and backbenchers Andrew Hastie, Andrew Broad and Sarah Henderson, were unsuccessful in trying to change the bill, as was Greens MP Adam Bandt.
Voting against the bill were three coalition MPs - Keith Pitt, David Littleproud and Russell Broadbent - as well as independent Bob Katter.
The names of those who abstained and voted for it were not recorded.
"I'd like to dedicate (Thursday's) win to a special group of young people and that is those young LGBTI Australians who in their workplace or their schoolyard find life a little tough," Senator Smith said after the vote .
"Let me tell you - you are OK, it will all be OK and this is a great country to grow up and be an LGBTI Australian in."
© AAP 2017