Australia became the 26th nation to legalize same-sex marriage on Thursday, prompting cheers and singing from a packed parliament public gallery in a country where some states ruled homosexual acts to be illegal until just 20 years ago.

Lawmakers, who had cast aside a conservative push to allow religious objectors to refuse service to same-sex couples, waved rainbow flags and embraced on the floor of the chamber, after the overwhelming vote in favor of the bill.

Fewer than five of 150 ministers of Parliament (MPs) voted against it.

"What a day. What a day for love, for equality, for respect," said Prime Minister Malcolm Turnbull. "It is time for more marriages."

The law, which will also recognize same-sex marriages solemnized in foreign countries, takes effect from Saturday. Because a month's notice is required for the state to recognize a marriage, the first legal same-sex unions will be in January.

Five-time Olympic gold-medal winner, the swimmer Ian Thorpe, who came out in 2014, said the law reflected contemporary Australia and would support people identifying as lesbian, gay, bisexual, transsexual queer, or intersex (LGBTQI).

"It will give each of us the sense of what modern Australia is, and is, in fact, the way that most of us see this country as being, and will allow LGBTQI people in our nation to know that fairness is one of our values," he told reporters in Canberra.

Australians had overwhelmingly endorsed legalizing same-sex marriage in a postal survey.

"What a moment for the country," said Christine Forster, a Sydney councilor and the sister of former Prime Minister Tony Abbott, standing among throngs of rainbow-clad campaigners for a "Yes" vote, outside parliament with her female partner.

She said she planned to go to her brother's house to celebrate.

Mr. Abbott, who is still a member of parliament, was one of the most prominent "no" campaigners. He left the chamber before the vote.

The bill cleared the upper house last month.

During the debate in the lower house on Monday, a politician proposed to his same-sex partner.

Both Mr. Turnbull's Liberal-National coalition government and the main opposition Labor Party had said they wanted to pass it by Dec. 7.

But despite the support of the main parties, religious organizations and conservative lawmakers had voiced strong opposition and proposed dozens of amendments.

During the debate, they pressed for broad protections for religious objectors, among them florists and bankers, to refuse service to same-sex couples.

But their efforts were rejected.

"These amendments, rather, are a shield for people and organizations that hold to a traditional view of marriage. They are not a sword to be wielded in the service of bigotry," government MP Andrew Hastie said in parliament.

Amendments to permit lay celebrants to decline to solemnize same-sex marriages and businesses opposed to the unions to refuse service at wedding receptions were all defeated, one after the other, during three days of debate.

Get the Monitor Stories you care about delivered to your inbox. By signing up, you agree to our Privacy Policy

"Love has won, and it's time to pop the bubbly," Greens MP and same-sex marriage supporter Adam Bandt said.

This story was reported by Reuters.