Draft legislation will allow gay and lesbian couples to marry with the same rights as heterosexual couples

The Scottish government is to introduce new powers to legalise same-sex marriages in churches and in civil ceremonies, despite vigorous and bitter opposition from church leaders.

A draft bill that will enable gay and lesbian couples to marry with the same legal rights as heterosexual couples will be published later this year and is expected to be enacted next year, after Scottish ministers resisted intense pressure from the Catholic church to drop the proposals.

The legislation will include significant new protections and "conscience clauses" for churches and individual clergy who object to gay marriage on religious grounds, said Nicola Sturgeon, the deputy first minister.

But she added that opposition to the bill – which included 64% of the 62,000 responses from within Scotland to the Scottish government's consultation – had not persuaded her to drop or dilute the measures.

"We believe that in a country that aspires to be an equal and tolerant society, as we do in Scotland, then this is the right thing to do," Sturgeon said.

"However, we recognise and respect the concerns that some have expressed, in particular the concerns that have been expressed by the churches. We are determined that the legislation which is brought forward will include protection for freedom of speech and freedom of religion."

The measures are expected to be passed by Holyrood next year before similar but weaker measures in England and Wales, to allow same-sex marriages in registry offices, are put before Westminster.

Sturgeon said she was confident it would be passed comfortably: all the party leaders at Holyrood supported the measure, and a majority of Scottish National party backbenchers did so. The SNP will give their 67 MSPs a free vote.

The Roman Catholic church, backed by senior Muslim organisations and evangelical and presbyterian churches, organised a huge postcard and internet petition campaign against the proposals.

But Sturgeon said detailed responses using the Scottish government's own online consultation document showed a majority in favour of gay marriage: by 65% to 35% against. Major public opinion polls also showed that most Scottish voters supported same-sex marriage, with about two-thirds of Scots in favour.

She said the Home Office in London had told Scottish ministers that the UK government is happy to amend the Equality Act to protect any clergy or celebrant who objects to their organisation's decision to allow gay marriages.

Under the new legislation, religious opponents of gay marriage will be protected from attacking the policy from the pulpit, she said.

Churches and celebrants who want to conduct same-sex ceremonies will have to "opt in" to the new powers, adding their names to a public register. Under the proposals, the first gay marriages in Scotland could be held in 2015, Sturgeon said.

"This is a very controversial issue. There is no getting away from that. There are very deeply held views on this issue on both sides of the debate. It is not possible to completely reconcile these different views. But as we proceed with this issue, the Scottish government will continue to be respectful of differences of opinion."

Gay rights and civil rights groups were jubilant.

Tom French, co-ordinator for the Equality Network umbrella group, said it was a "proud day" for Scotland.

"Same-sex marriage is about equality and freedom," he said. "The freedom for couples, and religious and humanist groups that want to, to celebrate same-sex marriages. But equally, upholding the freedom of other religious groups to say no to same-sex marriages. That's the right way for Scotland to deal with the different opinions on this."