Canberra, Australia (CNN) Australia's Parliament voted to legalize same-sex marriage Thursday after years of political jockeying and fierce public debate.

Cheers and applause broke out as lawmakers voted in favor of the bill following hours of debate and emotional speeches at Parliament House in Canberra.

"This is Australia: fair, diverse, loving and filled with respect for everyone," said an effusive Prime Minister Malcolm Turnbull, as he introduced the bill for a final vote.

"This is a great day, it belongs to every Australian."

"What a day for love, for equality, for respect. Australia has done it" - @TurnbullMalcolm . "Australia we are going to make marriage equality a reality in minutes" - @BillShortenMP . #marriageequality #auspol #7News pic.twitter.com/uIChPEOWfv

The bill passed its third reading with only four members of Parliament in opposition.

The parliamentarians who voted in favor of same-sex marriage took time to let the jubilant moment sink in, celebrating with hugs and handshakes and proudly sporting rainbow-colored clothing.

Liberal Member of Parliament Warren Entsch lifts Labor MP Linda Burney as they celebrate the passing of the marriage equality bill at Parliament House in Canberra, Australia, on Thursday.

In a particularly poignant moment, the ministers on the House floor and guests in the gallery began singing "I am, you are, we are Australian."

Public gallery erupts into chorus of 'I Am Australian' after Parliament votes to legalise same-sex marriage #auspol #SSM pic.twitter.com/uuoePCJamD — ABC News (@abcnews) December 7, 2017

The move follows a two-month national postal survey that showed 61% of more than 12 million respondents were in favor of marriage equality.

The country is now the 24th in the world to allow same-sex couples to marry, according to Pew Research

Australia's first same-sex weddings will not take place until at least January, however, because of a longstanding requirement for all Australian couples to provide a full month's notice of their intention to get married.

Historic moment

Marriage equality campaigners have fought for years for Thursday's vote. Though the bill was expected to pass into law without significant opposition, the lengthy legislative process was excruciatingly slow for the hundreds of advocates watching from the public gallery.

Among them was Christine Forster, the gay sister of Tony Abbott, the former Australian Prime Minister who has long been seen as the face of the "no" campaign.

Christine Forster, center, and her partner Virginia Edwards, third from left, attend a rally in support of marriage equality in May 2015 in Sydney.

Forster was joined in the public gallery by her partner, Virginia Edwards. They plan to marry next year, and Abbott has said he'll attend despite his personal views.

Abbott and other conservatives proposed amendments to the bill to include further religious protections, all of which were voted down.

Former Australian Prime Minister Tony Abbott -- considered the face of the campaign to reject same-sex marriage -- discusses amendments to the marriage equality bill at Parliament House on Thursday.

"These amendments are important and I stress they are not against same-sex marriage, they are simply in favor of the rights of religious organizations to keep doing what they're doing," Abbott said.

Opponents of the changes argued they would legalize discrimination against the gay community. The 500 or so people in the gallery were vocal in their disapproval of the amendments. They were warned multiple times that parliamentary rules prohibit them from making noise and even applauding.

Members of the public, including Christine Forster and partner Virginia Edwards, react from the gallery in Parliament House after legislators passed the same-sex marriage bill on Thursday.

An emotional week

After the bill passed the Senate last week, House proceedings kicked off with fireworks Monday when Liberal MP Tim Wilson surprised his colleagues by proposing to his longtime partner Ryan Bolger.

JUST WATCHED Same-sex debate leads to marriage proposal Replay More Videos ... MUST WATCH Same-sex debate leads to marriage proposal 00:50

The next day, Liberal MP Andrew Wallace, who is a devout Catholic, shared with his colleagues how his gay daughter helped change his position on same-sex marriage.

"She said: Dad, in the years to come, my generation will look back and judge your generation about how you deal with the issue of homosexuality in the same way that your generation considered your parents' generation in the way that they dealt with our indigenous people," Wallace said.

Fighting back tears, Liberal MP Sarah Henderson told the story Wednesday night of a close gay friend of hers who died months ago and who, in one of their last conversations, asked her to continue to push for same-sex marriage.

Liberal @SHendersonMP gave a powerful speech during the same-sex marriage debate. She spoke of her gay friend who recently died and had urged her to "bloody well get on with" changing the definition of marriage. #auspol @abcnews pic.twitter.com/0yUZUzN6mE — Caitlyn Gribbin (@CaitlynGribbin) December 6, 2017

Survey says yes

Thursday's vote comes three weeks after the Australian public voted overwhelmingly to legalize same-sex marriage as part of a national postal survey lasting two months.

Alice Bennett and her partner Miranda Hill nuzzle each other among a crowd who gathered to watch the announcement on a large television screen at Federation Square in Melbourne, Australia on December 7.

Under political pressure to find a solution, the ruling Liberal National Coalition government announced the non-compulsory survey in August, saying if the result was "yes" they would allow a free vote in Parliament.

In the end, 61.6% of Australia voted in favor of allowing same-sex marriage, with 38.4% saying "no."

About 12.7 million people participated in the survey, which had a response rate of nearly 80% -- which is considered very high.

Australians have long been in favor of same-sex marriage, with polling from as long as 10 years ago showing majority support for legalizing marriage equality.