Scotland's first same-sex marriages are set to take place later this year.
The Scottish parliament on Tuesday voted to pass the Marriage and Civil Partnership (Scotland) Bill by a margin of 105-18, with the first unions set to be conducted in the autumn.
"I believe this bill will have a hugely positive impact on our society and on the health and well-being of LGBT of people in our country," MSP Jim Eadie said during the debate. "Scotland now has one of the most progressive equal marriage bills in the world. Allowing the option of gender-neutral marriage ceremonies will provide genuine equality for all, including transgender people."
"This is a profound moment in our nation's history," he added.
Politicians cheered as the parliament gave its approval to the bill. It received cross-party backing, despite opposition from both the Scottish Catholic Church and the Church of Scotland.
Religious groups and officials authorised to conduct weddings will not be required to hold same-sex ceremonies. Instead they will have the freedom to opt-in to the law and conduct such ceremonies if they so which.
Same-sex marriage legislation for England and Wales was passed by the Westminster parliament in 2013, with the first marriages in those countries set to take place next month.
The exact date for the first same-sex marriage in Scotland depends on when the Westminster parliament amends existing legislation to ensure officials who refuse to conduct same-sex marriages are protected under the law.
Following a successful campaign by transgender activists the Scottish law will also end the so-called "spousal veto", which required transgender people to receive written permission from their spouse before their gender can be recognised in law. This rule remains in place across the rest of the United Kingdom.
There was limited opposition to the motion in the chamber, with a handful of MSPs failing in their attempt to push last-minute amendments that would increase legal protections for those who oppose same-sex marriage.
Scottish National Party MSP Richard Lyle, unsuccessfully tabled an amendment that aimed to ensure that those who want to adopt children are not refused on the basis of their opposition to same-sex marriage. He told the chamber that opponents of the law had received "vitriolic abuse" in recent months.
"Marriage is on the cusp of being changed forever," he said. "It is my conviction that marriage is a unique relationship between a man and a woman."
Fellow SNP politician John Mason voted against the bill and said he feared that "we are opening the door for more discrimination against religious people".
Scotland decriminalised homosexual acts between two consenting adults in 1980, thirteen years after England and Wales. Civil partnerships have been legal in the country since 2005.
Northern Ireland is now the only part of the United Kingdom where same-sex marriage legislation has not been passed, with few signs that the devolved assembly at Stormont will debate the matter in the near future.