Australia’s parliament has voted to allow same-sex marriage.

The decision follows a bitter debate settled by a much-criticised government survey of voters that strongly endorsed change.

The public gallery in the House of Representatives erupted with applause when the bill passed.

It changes the definition of marriage from solely between a man and a woman to “a union of two people” excluding all others.

The legislation passed with a majority that was not challenged, although five politicians registered their opposition. The Senate passed the same legislation last week 43 votes to 12.

After royal assent and other formalities, the law is likely to take effect in about a month, with the first weddings expected about a month later.

Champagne and tears of flowed in the halls of Parliament House as gay celebrities, including Olympic champion swimmer Ian Thorpe and actress Magda Szubanski, hugged politicians and ordinary people in a party atmosphere.

“What an amazing day, I’m a little bit delirious, it’s extraordinary,” said Szubanski, who sat in the public gallery during yesterday’s debate.

Thorpe thanked “our straight brothers and sisters” for strongly backing marriage equality in the postal survey.

“Quite literally without them voting for us, this would never have happened,” Thorpe said. “It means that we’ve created an Australia that is more equitable, it’s more fair, it’s more just.”

Amendments meant to safeguard freedoms of speech and religion for gay-marriage opponents were all rejected, though those issues may be considered later.

The government has appointed a panel to examine how to safeguard religious freedoms once gay marriage comes in.

Politicians advocating marriage equality had argued the national postal survey mandated a change of the marriage definition alone, so changing the law should not be delayed by other considerations.

Gay marriage was endorsed by 62 per cent of voters who responded to the postal ballot.

“It is now our job as members of parliament to pass a fair bill that does not extend or create any new discriminations,” an emotional MP Warren Entsch, who helped draft the bill, said.