WELLINGTON (Reuters) – New Zealand lawmakers passed a bill on Wednesday that would legalize euthanasia, paving the way for the public to vote on the issue in a referendum next year.

The bill, which enables terminally ill people to request a medically assisted death, was passed 69-51 in parliament, after several amendments and years of heated debate.

Previous attempts by lawmakers to legalize euthanasia have failed, and when the bill was introduced in parliament again in 2017 it was met with several concerns including the possible vulnerability of elderly patients being coerced.

The bill has since been amended with what its sponsors say are safeguards, including a requirement that patients be diagnosed as having less than six months left to live.

The patient must be the first to suggest assisted dying, and two doctors must agree that the patient is well-informed and other legal criteria are met.

The lawmaker behind the bill, David Seymour of the libertarian ACT Party, said people who are genuinely concerned have absolutely nothing to fear as there are robust safeguards in place.

“It is entirely about choice. Just as their rights and choices are respected, they will also need to respect the choices of others,” Seymour said.

The fate of the law rests in the hands of New Zealanders who will vote in a referendum at the general election which must be held by November next year. The pubic will also be voting in a referendum over legalizing recreational cannabis.

Recent polls have indicated that a majority support the measure to legalize euthanasia. However, there has also been a strong resistance from faith-based organizations, medical professionals and others. The bill received 39,000 public submissions, most of them opposing it.

Opposition National Party lawmaker Maggie Barry called it a “dangerous and permissive bill” and said it was important to stop it through the referendum. Dozens of protesters opposing the law gathered outside parliament on Wednesday holding placards that said “assist us to live, not die” and “euthanasia is not the solution”.

Many countries have legalized euthanasia, including Canada, the Netherlands, Switzerland, and some U.S. states.

(Reporting by Besa Chembo; Editing by Praveen Menon and Peter Graff)