See more of the story

– Australia's Parliament voted overwhelmingly Thursday to legalize same-sex marriage, overcoming years of conservative resistance.

Final approval in the House of Representatives, with just four votes against the bill, came three weeks after a national referendum showed strong public support for same-sex marriage. The Senate passed the legislation last week.

"This belongs to us all," said Prime Minister Malcolm Turnbull, a supporter of same-sex marriage who had previously failed to get it legalized. "This is Australia: fair, diverse, loving and filled with respect. For every one of us this is a great day."

After the vote, spectators in the public gallery began singing "I Am Australian," a well-known anthem. Lawmakers looked up at the gallery, some wiping tears from their eyes.

The new law expands on earlier legislation that provided equality to same-sex couples in government benefits, employment and taxes, and it changes the definition of marriage from "the union of a man and a woman" to "the union of two people." It recognizes same-sex marriages from other countries.

Gay rights advocates praised the landmark vote even as they said it was long overdue. In a country where there had been 22 unsuccessful attempts in Parliament to legalize same-sex marriage since 2004, they said, the law should be seen as the triumph of a democracy learning to live up to its values.

"This is a big victory," said Evan Wolfson, founder of Freedom to Marry, which led the U.S. campaign for marriage equality. "It is a huge affirmation of the dignity of gay people in yet another country, and that will reverberate in the lives of people across Australia and the world."

A handful of lawmakers tried to add amendments that they said were meant to safeguard religious freedoms for opponents of same-sex marriage, but their efforts failed. Turnbull noted that nothing in the legislation requires ministers or other celebrants to oversee weddings of gay couples or threatens the charity status of religious groups that oppose same-sex marriage, two concerns the lawmakers had raised.

The final debate in the House of Representatives, which lasted four days, featured more than 100 speakers.

On the first day, there was a marriage proposal: Tim Wilson, a gay member of Parliament, spoke of the struggles he and his partner, Ryan Bolger, had encountered as a couple, before choking up, finding him in the public gallery and asking: "Ryan Patrick Bolger, will you marry me?" The answer came loud and clear: "yes."

That was followed by hours of emotional speeches as politicians fell into a rare moment of consensus and moving closer to public sentiment, which polls show has favored same-sex marriage for years.