The Church of Scotland General Assembly has passed an historic vote that allows actively homosexual men and women to become ministers.

Assembly commissioners voted in favour of a proposal that allows liberal parishes to opt out of the church's policy on homosexuality.

The decision at the Kirk's annual gathering at The Mound in Edinburgh now has to be backed by the church's regional presbyteries and officially approved next month

The Divisions were caused when the first openly homosexual minister, Scott Rennie, was appointed in Aberdeen four years ago.

It led to two congregations and six ministers broke away.

The vote will follows a report by the church's Theological Commission, which sets out arguments on both sides.

General Assembly rules dictate it must be approved at a presbytery level and then rubber-stamped at next year's gathering.

It follows the appointment of the openly gay minister Scott Rennie was appointed to the Queen's Cross parish in Aberdeen in 2009.

He was backed by most of his congregation and by the General Assembly. However, that resulted in a protest and the break-away of a small number of congregations and ministers.

The Church had been expected to vote for one of three options today: to reject the future ordination of ministers in same-sex relationships, to treat openly gay ministers in the same way as heterosexual clergy, or to allow congregations to appoint ministers in civil partnerships whilst permitting individual congregations to opt out.

In fact, the Church voted in favour of a last-minute option brought to the table by a former Church kirk moderator, the Very Reverend Albert Bogle.

Church commissioners backed his motion to "affirm the Church's historic and current doctrine and practice in relation to human sexuality, (but) nonetheless permit those Kirk Sessions who wish to depart from that doctrine and practice to do so".

The  historic vote effectively means that the traditionalist position holds, but congregations will be able to choose themselves to have a minister in a civil partnership if they wish to do so.

Such a move will require certain Church regulations to be written and voted on at the 2014 General Assembly.

Gay campaigners welcomed the move. Equality Network's policy co-ordinator Tom French said: "We welcome this decision by the Church of Scotland, which is particularly important for the many LGBT people within the Church and their friends and family. This is a positive step forward for a more equal society, and speaks to the progressive values of 21st century Scotland."

Mr Bogle's motion was carried with 340 votes in favour in a final ballot on the issue.

The motion to allow congregations to appoint ministers in same-sex relations, with an opt-out option, fell after netting 282 votes.