Church members passed Reverend Bryan Kerr's motion with 345 votes against 370 during the general assembly.
This motion calls for a new law to be established to allow ministers to conduct same-sex marriages.
Scotland legalized non-religious marriage equality in 2014. Two years later, the church voted to allow ministers to perform same-sex marriages. On the other hand, there was some reluctance from ministers who didn't wish to conduct these ceremonies.
As a result, an amendment has been added. But the procedure takes a lot of time. The members of the church of Scotland only meet once a year.
Now the proposed law has to be reviewed by the legal questions committee of the General Assembly, which has two years to respond to the vote.
A final report is expected for 2021.
The church of Scotland is on track to allow religious same-sex marriages but we will have to be patient.