People attend a protest against the decriminalization of euthanasia in front of the parliament on February 20, 2020 in Lisbon | Patricia De Melo Moreira/AFP via Getty Images Portuguese parliament votes for euthanasia law Opponents demand referendum to halt legalization of medically assisted death.

LISBON — Portugal’s parliament on Thursday approved a bill to legalize euthanasia and assisted suicide, setting the country on course to join the handful of nations that allow mercy killing.

However, the legislation requires a second vote and opponents — who protested outside the parliament — are hoping to thwart the process by pushing for a referendum and challenges in the Constitutional Court.

The Portuguese vote follows a similar move last week in the lower house of the Spanish parliament. In both countries, the issue has provoked an impassioned debate.

“Assisting a peaceful death and ending useless suffering is a humane and deeply moral position,” said Isabel Moreira, of the governing Socialist Party. “To pursue as criminals those who help patients with incurable diseases is an affirmation of intolerance.”

Portuguese lawmakers voted in favor of separate bills presented by the Socialists and four smaller parties. All would allow euthanasia and assisted suicide for adults in sound mental health with incurable medical conditions and prolonged and extreme suffering. Patients’ requests to end their lives would need to be submitted at least twice and with the approval of at least two doctors.

“Life is a right, but it should not be an obligation to live with appalling suffering,” said Moisés Ferreira of the Left Bloc. “This is not about killing … it’s about help and empathy for the suffering of others.”

In 2018, an attempt to legalize euthanasia was defeated by five votes in the Assembleia da República. Elections in October, which returned the Socialist government of Prime Minister António Costa to power, changed the parliamentary arithmetic in favor of the right-to-die camp.

The Socialist proposal won most votes with 127 votes in favor, 86 against and 10 abstentions.

However, the vote cut across left-right divisions.

The Portuguese Communist Party joined conservative and far-right lawmakers in opposing the measure, which was supported by the Left Bloc, ecologist and animal-rights parties, plus a small center-right party.

“We still have time to avoid decisions whose social and human consequences we’ll regret in the future,” said Communist member António Filipe, who urged greater investment in palliative care in the public health system. “A decent country cannot oblige its citizens to choose between suffering and death.”

The Socialists and the main center-right opposition Social Democratic Party (PSD) gave their lawmakers a free vote. All but a handful the 108 Socialist lawmakers backed their party’s bill and a half dozen of the 79 PSD deputies — including party leader Rui Rio — voted for legalization.

Further debate and a second vote will be needed before the bill becomes law. Opponents, including the leadership of the Roman Catholic Church, are calling for a referendum to head off the law’s final approval.

Surveys show most citizens support euthanasia but a public vote could stymie the process because a turnout of over 50 percent is required to validate any referendum.

“Nobody is going to stop us. Today is just the start of this process,” José Maria Seabra Duque, secretary of the Portuguese Federation for Life, a campaign group, told the anti-euthanasia protesters outside parliament.

A petition with 60,000 signatures can trigger a referendum debate in parliament, but a majority of lawmakers is needed to call a public vote.

Portugal’s head of state, President Marcelo Rebelo de Sousa, a practicing Catholic, might also complicate the passage of the law by demanding further political debate or submitting legislation to review by the Constitutional Court. The Constitution states “Human life is inviolable.”

After overthrowing decades of ultra-conservative dictatorship in 1974, Portugal has shifted toward liberal social positions. It was among the first countries to legalize same-sex marriage and abortion laws have been progressively liberalized.

Within Europe, Belgium, the Netherlands and Luxembourg have legalized euthanasia and Switzerland allows assisted suicide. Canada, Colombia, Australia’s Victoria state and a number of U.S. states also allow some form of assisted death.