The clause is contained in the forthcoming gay marriage bill published at Holyrood yesterday as part of a deal with Westminster to amend the UK Equality Act.
However, the opt-out will not extend to commercial operations such as hotels or other groups involved in weddings, including chauffeurs.
It means even if a particular church or belief group chooses to take part in gay marriages, individual celebrants will still be allowed to opt-out if it goes against their personally held beliefs.
Campaigners let off colourful balloons and celebrated the launch outside the Scottish Parliament with Health Secretary Alex Neil.
They were joined by couples who are eager for MSPs to pass the laws so they can be allowed to marry legally, supportive church ministers and Holyrood politicians.
Members of the Humanist Society expressed concern there is to be no conscience clause for those who would be happy to be a celebrant a same sex union but whose faith group decides not to opt-in to do so.
"This means a law with rules of a one-way right of conscience is still biased and means this is still not equal," said spokesman Ross Wright.
Health Secretary Alex Neil said: "This is a historic moment for Scotland and for equal rights in our country.
"We are striving to create a Scotland that is fairer and more tolerant, where everyone is treated equally. That is why we believe same sex couples should be allowed to marry.
"A marriage is about love, not gender. And that is the guiding principle at the heart of this bill. At the same time, we also want to protect freedom of speech and religion, and that's what the bill sets out to do. That is why it will be up to the religious body or individual celebrant to decide if they want to perform same sex marriages and there will be no obligation to opt in."
Opponents of the reform, Scotland for Marriage said the governments had "demonstrated renewed contempt for the consultation process" and said of the bill: "The whole affair is an onslaught against the family, and the SNP is riding roughshod over the views of the majority of ordinary people.
They are guilty of pursuing dogma at the expense of debate and they demonstrate utter contempt for the democratic process in their unbridled pursuit of political correctness as they pander to the whims of a small minority with a loud voice."
The campaign claimed teachers could end up being sacked for refusing to teach gay history lessons.
The Free Church of Scotland spoke of "another step in the destruction of marriage as well as parenthood" and of "encouraging the existence of fatherless or motherless children."
Rev David Robertson, Free Church minister in Dundee and director of the Solas Centre for Public Christianity, said: "The Scottish Government is rushing into a major social change without thinking through the consequences."
Labour, the Liberal Democrats and the Greens all welcomed the publication of the bill.
Tom French, policy co-ordinator for the Equality Network, said: "After many years of campaigning for equal marriage we are delighted the bill has today started its journey into law.
"We hope our MSPs will stand by the values of equality and social justice the Scottish Parliament was founded on and vote to pass this bill with the strong majority it deserves. Thirty-three years ago Scotland finally decriminalised homosexuality, today the large majority of Scots agree it's time LGBT (lesbian, gay, bisexual and transgender) people were granted full equality under the law."
One couple outside the parliament, Jaye, 48, and Ruth Richards-Hill, 44, from Glasgow, said; "The launch of the equal marriage bill means so much to us as a couple. As our friends marry, many of them in a church, we stand on the sidelines like second-class citizens who are forbidden from joining the party."
If the bill is passed, Scotland's first gay weddings could take place in 2015.