Image caption Civil partnerships, but not same-sex marriage, are currently legal

A proposed bill to allow same-sex marriage in Scotland has been published at Holyrood.

The Marriage and Civil Partnership (Scotland) Bill aims to revise the law, while protecting rights of religious groups not to carry out ceremonies.

The plan will now undergo scrutiny before committee members and in the Scottish Parliament chamber.

Anti-gay marriage lobby group, Scotland for Marriage, promised to start targeting MSPs, urging them to vote no.

A spokesman said constituents would be encouraged to visit the politicians' surgeries and demonstrate outside their offices.

He added: "We can guarantee, we will not be going away.

"We will take our fight to the ordinary people of Scotland in cities, towns and villages across the country."

Analysis "Same sex marriage is controversial among MSPs but a clear majority are expected to support the legislation. "The First Minister, Alex Salmond, has said that SNP members will be allowed to vote with their conscience. Other parties will also allow a free vote. "All cabinet members are expected to vote for a change in the law, even if at least one deputy minister is unlikely to follow their lead. "There are opposing views within all three main political parties at Holyrood. "But it is not nearly as divisive for any of them as it was for the Conservatives at Westminster where almost half David Cameron's MPs voted against. "Even so, same sex marriage has been supported for England and Wales by votes in both the Commons and the Lords. "The equivalent legislation for Scotland is expected to receive final parliamentary approval early next year. "There will then need to be changes to the UK Equality Act to underpin the protections on religious freedom and freedom of speech. "It will be 2015 before gay and lesbian couples will actually be able to legally marry in Scotland."

The government said the bill would also allow civil ceremonies to take place at a location other than a registrar's office.

Talks have been taking place with the UK government because ministers at Holyrood believe an amendment is needed to UK equalities legislation to protect individual celebrants who may not want to conduct same-sex ceremonies even if their church, as an organisation, backs them.

Scotland's Health Secretary Alex Neil said the publication of the same-sex marriage legislation marked a "historic moment for Scotland and for equal rights in our country".

The Scottish government proposals also aim to protect the rights of religious celebrants and groups who are opposed to allowing gay couples to wed.

Mr Neil told BBC Radio Scotland's Good Morning Scotland programme: "We are striving to create a Scotland that is fairer and more tolerant, where everyone is treated equally. That is why we believe that same sex couples should be allowed to marry.

"A marriage is about love, not gender. And that is the guiding principle at the heart of this bill.

"At the same time, we also want to protect freedom of speech and religion, and that's what the bill sets out to do. That is why it will be up to the religious body or individual celebrant to decide if they want to perform same sex marriages and there will be no obligation to opt in."

After the bill was published, Lord Advocate Frank Mullholland issued legal advice in relation to comments that could be submitted as part of the government's same-sex consultation.

He said criticism of sexual orientation "is not in itself an offence".

Highly offensive

Mr Mullholland added: "People have the right to express their own opinions, particularly during the passage of the bill through the Scottish Parliament. Legitimate comment is part of the democratic process.

"The prosecution service recognises that freedom and also the sensitivity of the issues and the strength of opinion surrounding same sex marriage."

He said he had published the guidelines to "ensure a consistency of approach by prosecutors across Scotland in deciding whether it is in the public interest to prosecute a case where comments are made either in opposition to or in support of same-sex marriage which might be viewed as highly offensive".

The guidance points out the European Convention on Human Rights states that all people are guaranteed the right to freedom, conscience and religion, along with the freedom of expression.

SNP MSP Marco Biagi, who is gay, said it was now down to politicians to ensure the bill "does what it says on the tin".

Media playback is unsupported on your device Media caption Dr Gordon MacDonald: "It is not an issue of equality because of the legal rights of marriage now given to same-sex couples with civil partnerships."

He said: "The bill needs to maintain the freedom of religion for faiths who disagree, while also granting religious freedom for the first time to those faiths - like the Quakers - who have long wanted to perform same-sex ceremonies and have been forbidden from doing so."

The Equality Network, which supports the legislation, said it was time lesbian, gay, bisexual and transgender (LGBT) people were granted full equality under the law.

Spokesman Tom French said: "By passing equal marriage legislation our MSPs will not only be giving same-sex couples an equal right to celebrate their love through marriage, they will also be sending out a message to the world about the kind of fair and progressive country Scotland wants to be."

But Dr Gordon MacDonald, from Scotland for Marriage believed that same-sex marriage was not an issue of equality.

Speaking on BBC Radio Scotland's Good Morning Scotland programme, he said: "It is not an issue of equality because of the legal rights of marriage now given to same-sex couples with civil partnerships - is it is not a matter of equality at all."

He added: "Even if ministers of religion themselves can opt out, it doesn't mean that church buildings won't be used for this purpose against the wishes of their congregation."

Media playback is unsupported on your device Media caption Alex Neil: "A marriage is about love, not gender. And that is the guiding principle at the heart of this bill."

Scottish Liberal Democrat leader Willie Rennie said he hoped parliament would ensure "swift and effective passage" for the bill.

He added: "This is a great day for the LGBT community and signals an important, natural step towards the fairer Scotland we all wish to see."

But Conservative MSP Margaret Mitchell, whose Scottish party leader Ruth Davidson is gay, said she believed marriage laws should stay as they are.

She added: "I think it is now the rights of people who believe in marriage that are under fire and in danger. For that reason I don't see any need or necessity for same sex marriage - civil partnerships gave all the rights that were required and were long overdue."

Ms Mitchell's view was at odds with her Tory colleague Jackson Carlaw, who said he believed the bill's time had come.

He added: "As someone who has been happily married for 25 years, I see no reason why same-sex couples who wish to make the same commitment to one another should not be able to do so."