MSPs have rejected the Assisted Suicide Scotland Bill by 82 votes to 36 following a debate at Holyrood.
The bill would have allowed those with terminal illnesses to seek the help of a doctor to end their own life.
Supporters said the plan had widespread public backing but critics argued a change in the law would be unethical.
MSPs were given a free vote. The Scottish government did not support changing the law.
What did your MSP vote?
- 82 votes against the Bill
- 36 votes for the Bill
- 9 members did not vote
- 0 abstentions
The Assisted Suicide Bill was originally brought forward by the late independent MSP Margo MacDonald, who died last year after a long battle with Parkinson's disease.
It was taken up by Green MSP Patrick Harvie, who said he gave a commitment to Ms MacDonald to present this bill as best he could to parliament.
A Holyrood committee recently concluded that the bill contained "significant flaws" and opposed its general principles, but said the full parliament should decide whether or not to throw out the proposed legislation.
After the vote, Mr Harvie said he hoped the government would "recognise the strong demand for clarity in law".
He added: "It's clearly a disappointment that the Bill will make no further progress.
"The significant support in the chamber reflects the clear public desire for people to have choice and for the law to be clarified.
"I know many supporters of assisted suicide will now be hoping that the Lord Advocate issues prosecution guidance and that the Scottish government considers alternative approaches to the problem."
Scottish health secretary Shona Robison had earlier told MSPs: "The government believes that the current law is clear, and it is not lawful to assist someone to commit suicide, and the government has no plans to change that."
Despite that, she said, Scottish government ministers would be able to vote "according to their conscience", before adding that she would not be backing the legislation.
Conservative MSP Dr Nanette Milne, a former anaesthetist and cancer researcher who sits on Holyrood's Health Committee, also said she would not be supporting the bill.
She said: "Personally, as a former health professional, the idea of actively and deliberately hastening death by assisting someone to die is deeply disturbing for me. And I share the view of many professional colleagues that to legislate for this would risk undermining patient trust in doctors and medical advice."
But Liberal Democrat MSP Liam McArthur said, while the bill was not perfect, he would support its general principles.
He said: "Over the years I have come to the conclusion that the status quo is no longer tenable, that change is necessary, that finding ways of allowing individuals dignity in death as in life is now essential.
"It's a conclusion that growing numbers of people in Scotland have reached, often I suspect based on direct experience of what has happened to a family member or good friend.
"The right to life is not the same as a duty to live. This is about providing dignity, respect and choice at the end of life."
Assisted suicide - the legal position
It is not illegal to attempt suicide in Scotland, but helping someone take their own life could lead to prosecution.
In England and Wales, the Suicide Act 1961 makes it an offence to encourage or assist a suicide or a suicide attempt, which is almost identical to the situation in Northern Ireland.
The Director of Public Prosecutions (DPP) has to approve any assisted suicide court action in England, Wales and Northern Ireland.
In 2010, Keir Starmer, then the DPP, issued guidance that made it clear that family or friends who travelled with a loved one to the Swiss suicide group Dignitas would not risk prosecution.
The guidelines were the result of a case brought by Debbie Purdy, a terminally ill woman, who in 2009 won a legal ruling requiring the DPP to set out whether her husband would be committing an offence if he accompanied her to Dignitas to end her life.
Scotland's prosecution service, the Crown Office, has issued no such guidance.
Assisted suicide is legal in Luxembourg, the Netherlands and Belgium as well as Switzerland.
Campaigners who backed the bill, including representatives of the My Life, My Death, My Choice campaign, earlier gathered outside the Scottish Parliament to urge MSPs to support the general principles of the legislation.
But a number of organisations, including the Law Society of Scotland, Church of Scotland, Council of Imams Scotland and the Christian charity Care for Scotland, raised objections.
Alison Britton, convener of the Law Society's health and medical law committee, said she was concerned the law lacked clarity.
She said: "We have said throughout the passage of this bill that legislation in this area needs to be absolutely clear and those seeking to end their lives, and those who assist them, need a robust and transparent process to be certain under which conditions it would be lawful for assistance to be provided.
"We remain concerned over the lack of definition of the key terms, such as "assistance" and "life-shortening" and the functions of the licensed facilitator are still uncertain.
"Lack of such clarity leads to ambiguity and leaves the legislation open to interpretation."
And the Church of Scotland urged MSPs to do more to improve end-of-life care instead of backing the bill.
In a letter, Rev Sally Foster-Fulton, convenor of the Kirk's Church and Society Council, wrote: "We believe that this bill represents much more than simply a tinkering with the law, breaching as it does the societal prohibition on the taking of human life.
"It carries implications for the whole of society, not just for those who will seek assisted death, and for attitudes to many aspects of health and social care."
A report of the debate on the Assisted Suicide Bill can be viewed here.