The Scottish Parliament overwhelmingly voted in favour of legislation that will permit gay marriages - with the first such ceremonies now expected to take place before the end of this year.
The passing of the Marriage and Civil Partnership (Scotland) Bill, by 105 votes to 18, was hailed by equalities campaigners.
But religious groups who had strongly opposed the change said it had been "steam rollered through" as they declared it was a "sad day for those who believe in and who have fought for traditional marriage".
As the Bill was approved Scottish Health Secretary Alex Neil, who had steered the legislation through Holyrood, declared it was "one of the great historic days of the Parliament".
He said that was "not just because of the provisions of the Bill, but because of the message the Bill sends out about the new Scotland we are creating in the 21st century".
He stated: "Today is a momentous day for equality in our nation. No longer will persons of the same sex be barred from showing their commitment to each other through getting married.
"This legislation sends a powerful message to the world about the kind of society we in Scotland are trying to create - a nation where the principles of fairness and equality are weaved into the very fabric of our society, a nation that protects and promotes freedom of expression, a nation that cherishes love."
While MSPs at Holyrood discussed the legislation, equalities campaigners had rallied outside, setting off celebratory confetti cannons in anticipation of the Bill's approval.
Tom French, policy coordinator for the Equality Network, said afterwards: "Today will be remembered in history as the day that lesbian, gay and bisexual people were finally granted full legal equality in Scotland, and given an equal right to marry the person they love."
He added: "This is a profoundly emotional moment for many people who grew up in a country where being gay was still a criminal offence until 1980. Scotland can be proud that we now have one of the most progressive equal marriage bills in the world, and that we've sent out a strong message about the kind of country we are. We know this change means so much to lesbian, gay, bisexual and transgender people across Scotland and we look forward to the first same-sex marriages taking place as soon as possible."
Colin Macfarlane, director of Stonewall Scotland, said: "This a truly historic moment for lesbian, gay, bisexual and transgender people in Scotland. We're delighted that MSPs have overwhelmingly demonstrated that they're committed to building a Scotland fit for the 21st century."
But the Bill has polarised opinion in Scotland, with some church leaders viewing it as an assault on tradition.
A spokesman for the campaign group Scotland for Marriage said: "This has been a sad day for those who believe in and who have fought for traditional marriage.
"The overwhelming majority of MSPs have completely ignored public opinion and steam-rollered through a law which is ill-conceived, poorly thought out and will, in time, discriminate against ordinary people for their sincerely held beliefs."
The Rev David Robertson, a Free Church of Scotland minister in Dundee and director of the Solas Centre for Public Christianity, said: "Those of us who do not accept this redefinition of marriage and hold to the traditional view which has been the building block of our society, mourn this day.
"Not just because it is certain that we will now be discriminated against when we do not bow down to the new State absolutist morality, but because we believe that ultimately this will be detrimental to the people of Scotland, especially the poor and marginalised."
Legislation to allow gay marriage in England and Wales was passed at Westminster in July last year.
Under the legislation in Scotland religious bodies who wish to perform same-sex marriages have to opt in to do so. Protection will also be given to individual celebrants who consider such ceremonies to be contrary to their faith.
Alex Hamilton, convener of the Church of Scotland's Legal Questions Committee, said it adhered to the "mainstream Christian belief that marriage is properly between a man and a woman".
He added "opinion is also divided within Scotland about same sex marriage", saying: "We do not expect that our ministers would ever be forced to carry out same sex marriages.
"We are also concerned that public servants, particularly registrars and teachers, who do not support same sex marriage, may find themselves disadvantaged in the workplace.
"We continue to call upon the Scottish Government and Parliament to provide meaningful assurances that their freedom of conscience will be respected."