Scotland could become the first part of the UK to introduce gay marriage after the SNP government announced plans to make the change.
Ministers confirmed they would bring forward a bill on the issue, indicating the earliest ceremonies could take place by the start of 2015.
Political leaders, equality organisations and some faith groups welcomed the move.
But it was strongly opposed by the Catholic Church and Church of Scotland.
The announcement was made in the wake of a government consultation which produced a record 77,508 responses.
Same-sex couples in Scotland currently have the option to enter into civil partnerships and the Holyrood government has insisted no part of the religious community would be forced to hold same-sex weddings in churches.
The Scottish government said;
Scotland's deputy first minister, Nicola Sturgeon, said: "We are committed to a Scotland that is fair and equal and that is why we intend to proceed with plans to allow same-sex marriage and religious ceremonies for civil partnerships - we believe that this is the right thing to do.
She went on: "The Scottish government has already made clear that no religious body will be compelled to conduct same-sex marriages and we reiterate that today. Such protection is provided for under existing equality laws.
"However, our view is that to give certainty on protection for individual celebrants taking a different view from a religious body that does agree to conduct same-sex marriages, an amendment will be required to the UK Equality Act."
The Scottish government said it was now going ahead with another consultation to consider what extra measures are needed to guarantee freedom of speech, including the protection of religious beliefs of teachers and parents in schools.
Ministers said the Scottish Catholic Education Service would continue to decide on the faith content of the curriculum in Catholic denominational schools.
Welcoming the government's approach, Tom French, policy co-ordinator for the Equality Network, said: "Same-sex marriage is about equality and freedom - 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."
he Church of Scotland, which will report on its own investigation of the issue in May 2013, expressed concern the government was rushing ahead with its plans.
Stay informed. Subscribe to our newsletter
The Rev Alan Hamilton, convener of the Church of Scotland legal questions committee, said: "We are acutely aware that opinions differ among our own members and that many people are anxious and hurt in the current situation.
"We believe homophobia to be sinful and we reaffirm our strong pastoral commitment to all people in Scotland, regardless of sexual orientation or beliefs."
He added: "We are concerned the government will legislate without being able to effectively protect religious bodies or their ministers whose beliefs prevent them from celebrating civil-partnerships or same-sex marriages."
A spokesman for the Catholic Church in Scotland said: "The Scottish government is embarking on a dangerous social experiment on a massive scale.
"We strongly suspect that time will show the Church to have been completely correct in explaining that same-sex sexual relationships are detrimental to any love expressed within profound friendships."
Civil partnerships in Scotland offer the same legal treatment as marriage, but are still seen as distinct from marriage.
The UK government, which is consulting on changing the status of civil ceremonies to allow gay and lesbian couples in England and Wales to get married, wants to make the change by 2015.
-BBC