The Rev Scott Rennie dismissed claims the issue would divide the church
Church of Scotland leaders have voted to uphold the decision to appoint a gay minister to a church in Aberdeen.
The General Assembly of the Church of Scotland voted by 326 to 267 in support of the Rev Scott Rennie, 37, after more than four hours of debate.
Mr Rennie had been backed by the majority of the congregation at Aberdeen's Queen's Cross Church.
People on both side of the argument protested outside the meeting in Edinburgh.
Mr Rennie, a divorced father-of-one, is currently a minister at Brechin Cathedral and said he was open with the congregation at Queen's Cross about being gay and living with his male partner.
A number of people protested outside the General Assembly
Arriving at the assembly earlier, he said: "There are many gay ministers in the Church of Scotland and I hope that justice is done for them tonight."
He also dismissed claims the issue would divide the Church.
"The same talk was about when women were ordained and I think that argument suits those that don't want any change," he said.
He added: "We don't stone women, we don't stone adulterers, we've moved on from that."
However, more than 400 Kirk ministers and almost 5,000 Church of Scotland members are said to have signed an online petition opposing the appointment.
One of those ministers, the Reverend David Randall, said he believed that "a minister is somebody who ought to live by the Bible".
He said: "We believe that the Bible's teaching is quite clear in this matter - that marriage is the right and only context for sexual relationships."
The demonstration at The Mound in Edinburgh on Saturday was led by Pastor Jack Bell of the Zion Baptist Church in Glasgow.
"We are absolutely opposed to that on the basis of what God has to say about homosexuality in the Bible," he said.
A larger demonstration was help by supporters of Mr Rennie.
The Reverand Ewen Gilchrist, interim moderator at Queen's Cross, said there should be more acceptance.
"Sexuality is something that the church doesn't have a good track record about", he said.
"We constantly lock it up and frown about it. Here's an opportunity to welcome it, to acknowledge the diversity of human sexuality and to bring that richness into our life and worship."