The Church of Scotland has taken a step closer towards allowing blessings for same-sex marriages.
The General Assembly, meeting this week online and in Edinburgh, approved draft legislation that will allow ministers and deacons to marry same-sex couples.
It was two years ago, at the 2018 General Assembly, that the Legal Questions Committee was instructed to undertake a study of possible legislation to permit this.
The draft legislation presented at this week's General Assembly was approved by 319 votes to 217, and will now be passed to presbyteries for further consideration.
A report on their views will then be brought before the General Assembly in 2022.
The legislation will only come into effect if it is approved by a majority of presbyteries and then agreed by next year's General Assembly.
The Church of Scotland has already, since 2015, accepted gay ministers in same-sex marriages.
Under the draft legislation, traditionalist ministers will not be compelled to conduct same-sex marriage ceremonies. Nor will anyone be required to participate in or be involved in the arrangements for a same-sex marriage unless they explicitly wish to do so.
Rev John Purves, minister of Drumchapel St Andrews in Glasgow, who supports gay marriage blessings, said the draft legislation was "not a threat to anyone's strongly held beliefs or practice".
"We have already embraced the mixed economy," he said.
"What that decision achieved was not a compromise; quite the opposite.
"It created a provision whereby no-one had to compromise. There were fears expressed at the time that this might be divisive.
"On the contrary, what the last six years have proven is that far from dividing the Church of Scotland, this provision has promoted greater unity within the Church and values the beliefs of all."
Eric Smith, an elder at Brightons Parish Church in Falkirk, proposed a counter-motion that would send the draft legislation to the Theological Forum for further consideration.
"Over recent years the Church has gone through a painful process rooted to same-sex marriage," he said.
"It has consistently affirmed the traditional view of marriage between one man and one woman at the same time trying to amend and dilute this principal by offering the constrained difference approach.
"It appears that this is not based on a positive biblical theology for same sex-marriage but on an incremental chipping away at the biblical doctrine we as a Church continue to affirm in name."
His counter motion was defeated by 320 votes to 211.