Same-sex marriage will become legal in Australia after a historic bill was passed in the House of Representatives.
An overwhelming majority of MPs voted to change the Marriage Act, eight days after a similarly decisive result in the Senate.
The vote set off immediate celebrations in parliament, prompting cheers, applause and even a song.
The result brings an end to more than a decade of robust and often bitter debate on the issue.
“What a day for love, for equality, for respect,” said Prime Minister Malcolm Turnbull.
“Australia has done it.”
The legislation sailed through parliament without amendments after Australians overwhelmingly supported the reform in a voluntary national poll.
Australia’s governor-general is expected to approve the bill in the coming days, marking its official passage into law.
Emotional MPs hugged each other before supporters in the public gallery began singing “I am, you are, we are Australian”.
Earlier, many supporters had gathered on the lawn outside parliament. They included prominent same-sex marriage advocates, including former Olympic swimmer Ian Thorpe and local comedian Magda Szubanski.
More than 100 MPs had spoken on the legislation after it was tabled in the House of Representatives.
Many senators and MPs related personal stories in explaining why they supported the bill. One MP’s speech ended with a marriage proposal – a first for the lower house.
However, other politicians expressed their opposition.
“It is a special relationship between man and a woman for the purposes, if you are so lucky, for bringing children into the world,” Deputy Prime Minister Barnaby Joyce said on Thursday.
Keeping up with opinion
Hywel Griffith, BBC News Sydney correspondent
This is a big moment for Australian politics – the culmination of more than a decade of debate and indecision.
For a long time the issue of same-sex marriage was seen as too difficult and too divisive, and so it was hit into the long grass.
Campaigners watched with frustration as other countries, not least neighbouring New Zealand, made gay marriage legal.
There was a feeling, confirmed by the results of the postal survey, that Australia’s lawmakers had failed to keep up with public opinion.
Today’s vote won’t end the debate, or silence opponents of same-sex marriage – but it does mark the beginning of a new chapter.
The bill to amend the Marriage Act was first introduced in the Senate last month, immediately after a national poll showed 61.6% of Australians favoured change.
The bill includes exemptions for registered religious celebrants, who can refuse to marry same-sex couples on the basis of their faith.
Some conservative politicians had sought to extend exemptions to others, such as non-religious celebrants and businesses, but those proposals failed.
When will the first weddings happen?
The bill will require royal assent from Governor-General Peter Cosgrove, in what is considered a formality.
Same-sex couples will then be allowed to register to marry. Like heterosexual couples, they must wait 30 days after registration before a ceremony can take place.
Couples who wed overseas, or have already done so, will automatically have their marriages recognised in Australia.
Did the debate cause controversy?
Yes. The national vote, a voluntary postal survey, followed two failed attempts by the government to hold a compulsory poll that was twice voted down by the Senate.
Senators who opposed the compulsory vote did not necessarily oppose legalisation, but said the vote would be costly and fuel hate campaigns. They argued the matter should be put to a parliamentary vote.
Many same-sex marriage advocates levelled the same criticism at the voluntary vote, which did not require legislative approval.
During the eight-week survey, both supporters and opponents of same-sex marriage were accused of bullying and conducting misleading campaigns.
The controversy included frequent claims of vilification, while former Prime Minister Kevin Rudd blamed the survey for an assault on his godson.
More than 12.7 million people – about 79.5% of eligible voters – took part in the vote. It prompted jubilant scenes when the result was made public last month.