The announcement was made hours after the incoming Archbishop of Glasgow was accused of making unacceptable and homophobic remarks about a late MP.
Ms Sturgeon said: "We are committed to a Scotland that is fair and equal, and that is why we intend to proceed with plans to allow same-sex marriage and religious ceremonies for civil partnerships. We believe this is the right thing to do."
The decision comes after almost 80,000 people responded to a Scottish Government consultation on the issue.
The UK Government has also put forward proposals to bring in same-sex marriage, which it supports, but ministers are waiting until the end of a consultation before making a decision on the matter.
The planned legislation in Scotland will be accompanied by "important protections" for freedom of speech and religion, ministers said. No religious body will be compelled to conduct same-sex marriages, they confirmed, adding that protection for religious bodies which do not wish to conduct such ceremonies already exists under UK equality law.
The Scottish Government said that where a body does decide to conduct same-sex marriages, it intends to protect individual celebrants who consider such ceremonies to be contrary to their faith.
Such a stance is in line with the view expressed in the consultation, it was claimed. The SNP administration at Holyrood said that to give certainty around this protection, it considers that an amendment to the UK Equality Act is required.
Ms Sturgeon said: "The Scottish Government understands and respects the fact that there are very deeply held views in Scotland both for and against same-sex marriage and in coming to our decision, we have had to carefully consider a number of different factors.
"We are committed to a Scotland that is fair and equal and that is why we intend to proceed with plans to allow same-sex marriage and religious ceremonies for civil partnerships. We believe that this is the right thing to do.
"However, we are also deeply committed to freedom of speech and religion. The concerns of those who do not favour same-sex marriage require to be properly addressed."
A consultation will take place on the drafting of the legislation and guidance. It will consider any extra measures that may be needed to guarantee freedom of speech and religion in specific circumstances, including in education, ministers said.
A draft Bill will be published for consultation later in the year.
Earlier today it emerged that Bishop Tartaglia, the current Bishop of Paisley, and Archbishop-elect of Glasgow has been accused of making unacceptable and homophobic remarks about the at late MP.
Bishop Tartaglia had spoken publicly about David Cairns, a former Scotland Office minister who died of acute pancreatitis in hospital last May.
David Cairns's partner has called on Philip Tartaglia to apologise after he reportedly made comments linking the Labour politician's death to his homosexuality.
The archbishop-elect apparently raised the issue at a conference at Oxford University in April, reportedly saying: "If what I have heard is true about the relationship between the physical and mental health of gay men, if it is true then society is being very quiet about it.
"Recently in Scotland there was a gay Catholic MP who died at the age of 44 or so and nobody said anything. And why his body should just shut down at that age? Obviously he could have had a disease that would have killed anybody. But you seem to hear so many stories about this kind of thing, but society won't address it."
Religious Freedom and Equality: Keynote speech by Bishop Philip Tartaglia from The Berkley Center on Vimeo.
Mr Cairns's partner, Dermot Kehoe, hit out at the archbishop-elect's comments, accusing him of using the personal tragedy of the MP's death to make a political point about same-sex marriage. Mr Kehoe also said the "deeply painful" remarks added to the grief and pain felt by him and Mr Cairns's family.
Mr Kehoe told BBC Radio Scotland's Good Morning Scotland programme that the archbishop-elect "implied or stated that David's death was due in some way to his homosexuality and being gay".
This is "in complete ignorance of all the facts in this case", Mr Kehoe said.
"David died of pancreatitis, a gallstone blocked his pancreatic tract. So that's what happened to David, which could have happened to anybody.
"To take a personal tragedy like this and seek to use it to make a political point, it's more than upsetting, it's deeply painful.
"David and his family were parishioners and are parishioners of the bishop and he may have things he wants to say, based on scripture or based on theology about the issue of equal marriage. But to speak in this way in complete ignorance, not knowing any of the facts either about David's life or about his medical condition, is just an unacceptable way for someone to behave who seeks to show moral leadership.
"It's added to our grief and our pain."
Mr Kehoe called on the archbishop-elect to "understand what he has done and why is it wrong, why to take David's life and to tell people that David died because of his lifestyle when that is simply not true and there are no facts to support that".
He said: "I want him to show contrition for that and to apologise."
When asked if the bishop's comments are homophobic, Mr Kehoe replied: "Yes. He said three things. He said gay Catholic MP, and to him somehow the word gay appears large in this. This must explain everything.
"It's generalising on the basis of ignorance. It's taking something you know nothing about and saying it's because he's gay, that's the definition of prejudice."
With the Catholic Church strongly opposed to same-sex marriage, Archbishop-elect Tartaglia said yesterday that he would continue to defend his position on the issue.
"I don't get involved in politics for politics' sake. It's to do with issues which affect human life and flourishing."
Mr Kehoe argued that the debate should be about the issues, rather than "individual tragedies".
He said: "Let's talk about marriage and relationships because that is what the issue is really about, and let's not bring in individual tragedies and speak from ignorance."
A spokesman for Bishop Tartaglia said: "Responding to a question from an audience member, following a lecture some months ago, Bishop Tartaglia agreed that the health risks of same-sex behaviour were largely unreported.
"He mentioned the premature death of a young, high-profile gay MP in this context.
"There was no intention to cause offence and he regrets that anyone may have been upset. The church will always be willing to offer pastoral care to those in need and in the case of the MP concerned, his funeral was conducted in the Catholic Church and pastoral support offered to his family and friends."
He said it was difficult to keep it secret, particularly when he was "interrogated" by his sisters on holiday.
First Minister Alex Salmond offered his congratulations on the appointment.
He said: "Our country's newest Archbishop has already played a distinguished role across Scotland and Scottish society as a whole. His pride at being appointed in his native city will be matched by the pride he felt in the Diocese of Paisley, which he dutifully served as Bishop for nearly seven years.
"It is in that role that I have met Bishop Tartaglia and discussed with him the importance of celebrating the contribution that the Catholic Church, along with other churches and faiths, has made to Scottish life.
"I congratulate him on this richly deserved appointment and I look forward to meeting him regularly in the months ahead."
Mr Salmond also praised the contribution retiring Archbishop Conti has made to the country.
He said: "He has served not only Glasgow but the north-east of Scotland with dedication and sincerity for many years, and so many of us are grateful to him for his service.
"Archbishop Conti's decade-long tenure can be no better marked than with the magnificent reconstruction of St Andrew's Cathedral in Glasgow and its memorial garden.
"This is a great symbol of his archdiocese, and as a great supporter of culture as well as his church I am sure that Mario Conti will continue to shape Scotland for the richer."
Archbishop Tartaglia believes he faces big challenges in his new role.
"The Church has a core mission which carries on from generation to generation despite any other circumstances which are going on in the world, we have to preach the gospel and support the faith of our people," he said.
"One of the priorities will be how do we evangelise effectively when fairly serious godlessness is being promoted in our society.
"How do we educate and inform our youth? These are the kinds of issues which will emerge."
He also said he would continue to defend his position on same-sex marriage legislation.
"I don't get involved in politics for politics' sake, it's to do with issues which affect human life and flourishing.
"We consider same-sex marriage as a very important issue and will continue to make our point. Associated with this is the whole issue of religious freedom and religious liberty which we think is very much implied in what the Government wants to do.
"I will not be looking for confrontation with the Government for its own sake but what we have to do is speak up for what we see as the truth of the human condition."
Archbishop Tartaglia found out about his appointment on July 5 while on a pilgrimage in Lourdes, France.