A change in the law that will allow same-sex couples in Scotland to marry has been approved in a "historic" vote at Holyrood.
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: "T his 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: "T his has been a sad day for those who believe in and who have fought for traditional marriage.
"T he 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 "o pinion 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."
During the debate at Holyrood, attempts to add ''protection'' for religious groups opposed to same-sex marriage were rejected by MSPs.
SNP backbencher John Mason had hoped to alter the legislation to ensure no one is ''compelled by any means'' to solemnise gay marriage.
His was the first of a series of backbench amendments seeking to bolster protection in the Bill for freedom of expression.
''If the Parliament accepts none of these amendments this afternoon, we are sending out a signal that we've not been listening,'' he argued.
Mr Neil insisted however that the legislation already protects celebrants who do not want to take part in ceremonies.
While he conceded that churches had concerns, the Health Secretary stated: ''There are robust protections for religious bodies and celebrants in the Bill and in the planned amendments to the Equality Act.''
An amendment has been agreed to the UK Equality Act which should provide further protection for individual celebrants who did not wish to conduct same sex weddings from court actions claiming discrimination, Mr Neil said
Labour's Jackie Baillie backed the Bill, stating: ''It's time for change, it's time to support equal marriage.''
She insisted gay marriage was ''an idea whose time has come'' adding: ''For me this Bill is about equality, fairness and social justice, values instilled in many of us by our parents, our community and by society.
''For many of us the Bill is also about how we see ourselves as a nation and how others see us. It's about the values we hold and whether Scotland is indeed a confident progressive nation, where equality is truly valued.''
Tory MSP Jackson Carlaw said: "I regard today as a fantastic, celebratory change in the mood, style, signature and stamp of my country, Scotland.''
Meanwhile Liberal Democrat MSP Jim Hume said: ''In passing this legislation today, we're making the proud statement that we're not content to isolate a section of our diverse community. We're not giving preferential treatment to any one group.
''We're simply saying that everyone, regardless of sexual orientation, should have the same rights. Anything less is inhumane.''
Scottish Quaker Phil Lucas said: "Scottish Quakers are delighted that this Bill has been passed which will bring marriage equality to Scotland, which we have been working towards.
"Quakers warmly support this move and look forward to celebrating such marriages in our meeting houses."