The country voted overwhelmingly in favour of the move last month
Australian members of parliament have endorsed the nation's vote to allow same-sex couples to marry, before bursting into song.
Only four MPs did not back the historic reform, which comes after the country voted overwhelmingly in favour of legalising gay marriage last month.
Onlookers in the packed public gallery, hugged, cheered loudly and started applauding and waving their rainbow flags while singing "I Am Australian".
"We are one, but we are many," they belted out in unison.
"And from all the lands on earth we come. We'll share a dream and sing with one voice. I am, you are, we are Australian."
Several politicians on the floor of the chamber joined in. One could be seen wiping away a tear.
Here's the moment Australian parliament voted to legalise same-sex marriage and started singing "We Are Australian". pic.twitter.com/DexvOUC9WQ— Alice Workman (@workmanalice) December 7, 2017
"What a day for love, for equality, for respect. Australia has done it," Australian Prime Minister Malcolm Turnbull said.
"This is Australia, fair and diverse, loving and filled with respect."
"Love has won and it's time to pop the bubbly," Greens MP and same-sex marriage supporter Adam Bandt said.
"It's an historic day for Australia today and I think the celebrations around the country when we finally ... achieve marriage equality are going to be immense," Janet Rice said before the vote.
The Green Party senator was only able to remain married to her transgender wife of 31 years, Penny Whetton, because Penny remained listed as male on her birth certificate.
Penny Wong, a Labour Party senator who has two children with her lesbian partner, said: "I am feeling happy."
Campaigners gathered outside the building rejoiced at the news.
The law is expected to be ratified within days, making Australia the 26th nation to legalise same-sex marriage, after some of its states ruled homosexual acts to be illegal until just 20 years ago.
The first legal same-sex unions will be allowed from January.
The existing bill allowed churches and religious organisations to boycott gay weddings without violating Australian anti-discrimination laws.
As the new bill was introduced and debated on Monday, MP Tim Wilson, from the ruling Conservative Party, fought back tears as he proposed to his partner - Ryan Bolger - in the country's House of Representatives.
On Tuesday, Austria's supreme court ruled to legalise same-sex marriage in the country from January 1st 2019.