New Zealand has voted to legalise euthanasia in what campaigners have called "a victory for compassion and kindness".
Preliminary results showed 65.2% of voters supported the End of Life Choice Act coming into force as a new law.
The law will allow terminally ill people with less than six months to live the opportunity to choose assisted dying if approved by two doctors.
Its opponents say the law lacks adequate safeguards.
The referendum results announced on Friday do not include an estimated 480,000 special votes, including overseas ballots, so the final outcome will not be confirmed until 6 November. But with such strong support, the decision is not expected to change.
The referendum is binding and the law is expected to come into effect in November 2021.
It will see New Zealand join a small group of countries, including the Netherlands and Canada, which allow euthanasia.
The referendum on assisted dying was held alongside the general election earlier this month. In a separate non-binding referendum held at the same time, New Zealanders narrowly rejected a proposal to legalise recreational cannabis.
The preliminary results on the cannabis vote was 53.1% no and 46.1% yes - though this result may be subject to change when the special votes are counted.
What has the reaction been?
The "yes" verdict had been anticipated after polls suggested strong public support for the law, which was also backed by Prime Minister Jacinda Ardern and the opposition leader, Judith Collins.
But it was the result of an emotional, years-long campaign with strong views on both sides of the debate.
For Matt Vickers, who took on his late wife Lecretia Seales' fight to legalise assisted dying, the result is "a victory for compassion and kindness".
"I am grateful that terminally ill New Zealanders will have a say about the ends of their lives," he told the BBC after the announcement.
Ms Seales was a lawyer who launched a legal challenge for the right to end her life with medical assistance after she was diagnosed with a brain tumour. But her case was unsuccessful and she died of her illness five years ago, aged 42.
Mr Vickers pressed on with her campaign and in 2016 his book, "Lecretia's Choice: A Story of Love, Death and the Law", was published.
The day before the result Mr Vickers told the BBC that ultimately his late wife's goal was for terminally ill people to have the choice that she was denied.
"She didn't want to die. No one does. That's a popular misconception. The problem was the choice to live had been taken away," he said. "She wanted a choice on how death happens so if things got bad she could end the suffering at the time she wanted."
Ms Seales' case went on to play a pivotal role in raising awareness about assisted dying, catalysing New Zealand politicians to address the issue.
What is the new law?
The End of Life Choice Act was passed by parliament in 2019 after years of heated parliamentary debate and a record number of public submissions.
But there was a proviso that it would first be put to a referendum, only coming into force if more than 50% of voters ticked "yes".
There are a number of criteria a person must meet to ask for assisted dying. These include:
suffering from a terminal illness that's likely to end their life within six months
showing a significant decline in physical capability
being able to make an informed decision about assisted dying
The legislation authorises a doctor or nurse to administer or prescribe a lethal dose of medication to be taken under their supervision if all the conditions are met.
The law also says a person cannot be eligible for assisted dying on the basis of advanced age, mental illness, or disability alone.
What do opponents say?
While there is widespread support for euthanasia reform, there has also been vocal opposition.
As MPs voted on the bill last year, protesters had carried placards stating "assist us to live not die" and "euthanasia is not the solution" outside parliament.
Euthanasia-Free NZ, a group that campaigned to vote "no", has said that euthanasia poses a threat to the well-being of society. Among its concerns are that the legalisation of assisted dying would contradict and undermine suicide prevention.
Others have voiced worries about people with chronic conditions potentially feeling obliged to use euthanasia to avoid being a burden on their families.
On Friday Euthanasia-Free NZ said it was "disappointed that the New Zealand public voted to pass a flawed euthanasia law". In a statement it added that parliament "could have made this law safer" by passing further amendments.
Which countries allow euthanasia?
The referendum result in New Zealand will be closely watched by advocates for and against assisted dying throughout the world.
By voting "yes" the country is joining a small group of nations and territories that have passed similar legislation.
Euthanasia is legal in Belgium, Canada, Colombia, Luxembourg and the Netherlands, while assisted suicide is permitted in Switzerland.
A number of states in the United States and the Australian state of Victoria have also made assisted dying legal.
Euthanasia is the act of deliberately ending a life to relieve suffering, while assisted suicide is the act of deliberately assisting another person to kill themselves. In contrast to euthanasia and assisted suicide, assisted dying would apply to terminally ill people only.
If you've been affected by issues in this article, help and support is available via the BBC Action Line.