The synod vote received support from five of seven bishops, 69% of the clergy and 80% of the laity - indicating that it has a good chance of succeeding when it returns next year.
If passed it would means Scottish Episcopal's would become the first major church in the UK to marry gay and lesbian couples in church.
This level of action is not happening within the Church of England, which will not conduct gay marriages, or allow clergy to be in a same-sex marriage.
The Scottish move could intensify the split within the wider Anglican Communion of 85 million Christians.
In January the Communion sanctioned the US Episcopal Church when it decided to allow gay marriage in church.
The church’s leader, the Archbishop of Canterbury, has struggled to keep the Communion together over the issue.
Lambeth Palace said the archbishop would not be commenting on the decision.
Speaking after the vote, the secretary-general of the Anglican Communion, Archbishop Josiah Idowu-Fearon, said: “The churches of the Anglican Communion are autonomous and free to make decisions about policy.
"Today's decision is only the first step in the process of changing canon law on marriage.
“I would echo what the Archbishop of Canterbury said recently in Zimbabwe on same-sex marriage: there are differing views within the Anglican Communion but the majority one is that marriage is the lifelong union of a man and woman.
"He also stressed our primates' opposition to the criminalisation of LGBTIQ people."
Same sex marriage became legal in Scotland at the end of 2014 but Scotland's main churches - the Church of Scotland and the Roman Catholic Church - opposed the move.
The legislation was designed to allow religious and belief bodies to “opt-in" if they wanted to perform same-sex marriages.
The Scottish Episcopal Church is a Christian church with an estimated 90,000 adherents in Scotland.
Its synod is being held at St Paul’s and St George's Church in Edinburgh.
The Right Reverend Dr Gregor Duncan, Bishop of Glasgow and Galloway and acting convener of the church’s Faith and Order Board, said: "The synod's decision this year is important because it represents the beginning of a formal process of canonical change.
"The church has been engaged in recent years in a series of discussions at all levels.
“The current process will enable the Church come to a formal decision on the matter."
Keith Porteous Wood, of the National Secular Society, said: "This will put huge pressure on the Anglican and the many other churches to wave through same sex religious marriage. It is just a matter of time before more do so.”