Image caption The Scottish government's bill was backed in principle by MSPs, after a vote at Holyrood

Legislation to introduce same-sex marriage in Scotland has been approved in principle by parliament, after MSPs voted on it for the first time.

The Scottish government's Marriage and Civil Partnership Bill passed the first of three parliamentary hurdles by 98 votes to 15 with five abstentions.

Ministers said the move was the right thing to do, but the Church of Scotland and Catholic Church are opposed.

Religious and belief bodies would "opt in" to perform same-sex marriages.

Same-sex couples in Scotland currently have the option to enter into civil partnerships, and there has been an indication that the earliest gay marriage ceremonies could take place by the start of 2015, if the legislation is passed.

Since indicating that I did not intend to support the redefinition of marriage, it was suggested that I be burnt at the stake as a witch Elaine Smith, Labour MSP

Ministers have insisted no part of the religious community would be forced to hold ceremonies for homosexual couples in churches.

For the Scottish government, Health Secretary Alex Neil said of the bill: "I believe that will allow all people having the same opportunity as each other in Scotland who love each other to have their marriage recognised in the eyes of the law.

"That will create a more tolerant society in Scotland and will mean that, in respect of marriage, there is genuinely equal rights right across the entire community."

MSPs were allowed a free vote on the legislation, rather than along party lines, and members spoke out on all sides of the debate.

Scottish Conservative leader Ruth Davidson, who is openly gay, told parliament of her respect for the institution of marriage, adding: "I want that right to extend, not just to me, but also to the thousands of people across Scotland who are told that the law says 'no'.

"They can't marry the love of their life, they're not allowed. And unless we change this law, they will never be allowed."

Labour MSP Mary Fee also supported the bill, telling MSPs: "Having been married for 36 years and raised two children, I strive to understand how introducing this legislation takes anything away from my marriage."

The Liberal Democrats' Jim Hume, also backed the legislation, adding: "This is not just another bill today - it is a reform in our society - a demonstration that our Scottish society values everyone - no matter their sexuality - and no matter their relationships."

And Green MSP Patrick Harvie said the bill was a "proud achievement" for Scotland, while highlighting what he said were the "backward steps" being taken in countries like Russia in relation to gay rights.

But SNP MSP John Mason opposed the bill, saying the two main arguments against it were that marriage was between a man and a woman, and that the legislation failed to provide proper protection for others who did not agree.

Marriage bill - key measures Civil marriage ceremonies can take place anywhere agreed by the registrar and the couple, other than religious premises. Religious and belief bodies opt in to perform same-sex marriage. Celebrants who are part of an organisation which has not opted in would not be allowed to conduct same-sex marriages.

Individual celebrants who felt it would go against their faith to carry out same-sex weddings would be protected. Establishing belief ceremonies, such as humanist ceremonies as a "third form of marriage", alongside religious and civil events. Authorising Church of Scotland deacons to solemnise opposite sex marriage. Possible tests for religious and belief bodies to meet when solemnising marriages or registering civil partnerships, in light of increasing concerns over sham and forced marriages. Introducing religious and belief ceremonies to register civil partnerships. Allowing transgender people to stay married, rather than having to get divorced, when obtaining a Gender Recognition Certificate. Provision making it clear that the introduction of same-sex marriage has no impact on existing rights to freedom of speech and that it is possible oppose to same-sex marriage "without being homophobic". Amended guidance on the teaching of the issue in schools. An intention to recognise same-sex marriages registered elsewhere in the UK and overseas.

He added: "Parliament is not reflecting public opinion on this issue.

"It can be argued whether those supporting or opposing the bill have the greater numbers on their side, but there is certainly not the overwhelming support outside this place that there seems to be inside."

Labour MSP Elaine Smith, another opponent to the bill, argued that it failed to protect freedom of speech for those who were against gay marriage, adding that she hoped MSPs had not been "bounced" into voting "Yes" because of a fear of being branded homophobic.

She told parliament: "Since indicating that I did not intend to support the redefinition of marriage, my religion's been disparaged, I've been branded homophobic and bigoted, I've been likened to the Ku Klux Klan and it was suggested that I be burnt at the stake as a witch."

Conservative MSP Alex Johnstone expressed concern that traditional marriage could be undermined by the bill.

He said: "During my lifetime, I have seen society beginning to fall apart.

"That's why I would argue that one of the priorities of this parliament should be to strengthen families, to find ways to reinforce marriage and to make sure that we reverse the trends of half-a-century and more, in order to gain that stability.

"That's why I worry that we are making this a wrong priority at the wrong time."

Gay rights organisations, including the Equality Network and Stonewall Scotland, and a range of other groups, have supported the legislation.

Stonewall Scotland director Colin Macfarlane, said: "As the last piece of the legislative jigsaw providing equality for lesbian, gay, bisexual and transgender people in Scotland, this is a truly historic step forward."

However the campaign group Scotland for Marriage said the safeguards in the bill did not go far enough.

Rev Dr Alan Hamilton, from the Church of Scotland, said the institution stood against homophobia.

But he added: "We also recognise that there is a wide spread of public opinion about whether legalising same sex marriage is the right thing, and that spread of public opinion is reflected among members of our congregations across the country."

As well as the main bill, Scottish ministers have also reached an agreement with the UK government for an amendment to the 2010 Equality Act.

The move aims to protect individual religious celebrants, who do not wish to conduct same-sex marriages, from the threat of court action claiming discrimination.

The marriage bill was brought forward after a Scottish government consultation, which produced a record 77,508 responses.

In England and Wales, the passing of the Marriage (Same sex couples) Act in July has paved the way for the first gay and lesbian wedding ceremonies to take place by summer next year.

It will allow religious organisations to "opt in" to offering weddings, with the Church of England and Church in Wales banned in law from doing so.