Same-sex marriage will be legal in Australia, with Parliament agreeing to change the Marriage Act and end the ban on gay and lesbian couples marrying.
Four members of the House of Representatives voted against the bill.
Liberal senator Dean Smith's bill will now become law after a day of cheers, tears and applause in the Lower House.
People queued for access to the public gallery to witness the law being changed and by the time of the final vote, they were packed into every spot.
Same-sex marriage supporters wearing colourful "Yes" T-shirts clapped and cheered as amendments were voted down, prompting repeated warnings they should stop their barracking.
The public gallery led a chorus of We Are Australian after the final vote, with members of the parliament joining in from the floor of the House in tears.
There had been little doubt that this bill would pass with sweeping support from Nationals, Liberals, Greens, the crossbench and Labor.
Opponents of same-sex marriage including Liberals Andrew Hastie, Kevin Andrews and Tony Abbott pushed for changes, but none of their amendments succeeded.
The legislation passed the Lower House three weeks after Senator Smith stood in the Senate and declared "it was not just a vote about a law but a vote about who we are as a people".
Senators supporting the bill huddled together on the side of the Lower House chamber to join the celebrations.
Veteran same-sex marriage campaigner Warren Entsch was besieged by his colleagues.
Earlier gay Liberal MP Trent Zimmerman noted Mr Entsch's long-standing advocacy, lauding him as an "honorary gay".
How did we get here?
It has been 13 years since the Howard government changed the Marriage Act to ensure same-sex marriage could not be legal.
From that point, the Greens and Australian Democrats made repeated but unsuccessful attempts to overturn that decision, and Mr Entsch came to prominence with his passionate advocacy to allow gay marriage.
Five years ago, parliament had three bills before it to try to allow same-sex marriage: one in the Senate from the Greens, another a joint bill in the Lower House from Green Adam Bandt and independent Andrew Willkie, and a third from Labor's Stephen Jones. None succeeded.
The pivotal and ultimately successful manoeuvre came quietly and carefully more than a year ago.
It was a masterclass in political technique.
The Coalition's policy for a plebiscite was blocked in the Senate, but Attorney-General George Brandis started to ease the political gridlock by producing a draft bill anyway.
That was on the basis that if a plebiscite was actually held and voters supported same-sex marriage, then a bill would be needed.
More political guile was evident in the way a Senate committee was chosen to examine that bill, with members including Senator Smith and fellow gay senator Louise Pratt, from Labor, as well as opponents of same-sex marriage like Nationals senator John Williams.
In a unanimous report, the committee laid the groundwork for the process that has ended today, by finding a way through the passionately held views on both sides of the debate.
It set out that ministers of religion should be exempt from conducting same-sex marriages, finding there was consensus that religious freedom should be protected.
And crucially it said marriage could be simply defined as between two people.
Today's vote implements that, and the House of Representatives has overturned the change made by the Howard government in 2004 to limit marriage to being between a man and a woman.