Australia is a step closer to legalising same-sex marriage after lawmakers passed a bill in the Senate.
The bill, which originated in the upper house, will now be debated in the House of Representatives. If approved there, it will become law.
The legislation was introduced after a national vote showed decisive support for legalising same-sex marriage.
Senators passed the bill 43-12 on Wednesday, after rejecting proposed amendments by conservative lawmakers.
The result was read out to applause and cheers in the chamber, as senators embraced each other.
Attorney-General George Brandis, the government's Senate leader, said the legislation would "demolish the last significant bastion of legal discrimination" over sexuality in Australia.
"By passing this bill, we are saying to those vulnerable young people there is nothing wrong with you. You are not unusual. You are not abnormal. You are just you," he said on Tuesday, when the main debate took place.
The bill allows exemptions for those classed as "religious marriage celebrants" who do not want to perform same-sex ceremonies on the basis of their faith.
Some government senators had tried to extend the exemptions to include civil celebrants, but that push was voted down.
A conservative amendment to create two definitions of marriage - one between a "man and a woman" and another between "two people" - was also rejected, as was one allowing parents to remove their children from schools over same-sex marriage teachings.
The bill drew heartfelt speeches from many senators after it was introduced by government Senator Dean Smith with broad cross-party support.
The legislation was tabled hours after a non-binding national poll showed that 61.6% of Australian voters were in favour of change.
Some same-sex marriage advocates were present in the Senate for the vote on Wednesday.
"It's a huge victory for love, for equality and fairness," said one supporter, Anna Brown.
Mr Brandis said legalising same-sex marriage would be the "imperishable legacy" of Prime Minister Malcolm Turnbull's government.
Opposition parties have previously accused the government of delaying parliamentary debate on the legislation so it could hold the national survey.
The debate in the House of Representatives will begin next week. The government has said the house will not adjourn until the legislation is passed.