After a long battle, Portugal on Friday passed a law legalising euthanasia for people in great suffering and with incurable diseases, joining just a handful of countries around the world.
The issue has divided the deeply Catholic country and witnessed strong opposition from conservative President Marcelo Rebelo de Sousa, a devout churchgoer.
Under its provisions, people aged over 18 will be allowed to request assistance in dying if they are terminally ill and in intolerable suffering.
It will only cover those suffering "lasting" and "unbearable" pain unless they are deemed not to be mentally fit to make such a decision.
The law will only be applicable for nationals and legal residents and not extend to foreigners coming into the country to seek assisted suicide.
The euthanasia bill was approved by parliament four times in the last three years but sent back every time for a constitutional review due to opposition from the president.
The definitive version of the law was adopted on Friday with support from the governing Socialists, who hold an absolute majority in the chamber.
"We are confirming a law that has already been approved several times by a huge majority," said Socialist MP Isabel Moreira, a fervent advocate of legalising euthanasia.
The president now has a week to promulgate the new law. It could come into force by the autumn, Portuguese media said.
"We have at last come to the end of a long battle," Moreira told AFP earlier this week.
Rebelo de Sousa had vetoed earlier bills due to "excessively undefined concepts" and later said the language used to describe terminal conditions continued to be contradictory and needed to be clarified.
The new version of the law now provides that euthanasia is only authorised in cases where "medically assisted suicide is impossible due to a physical disability of the patient".
Rebelo de Sousa has asked lawmakers to specify who would "attest" to whether a patient was physically incapable of assisted suicide but lawmakers this time refused to modify the text.
Questions raised by the president can be addressed through implementing decrees, said Catarina Martins, the leader of the far-left Left Bloc.
Rebelo de Sousa himself said approval of the law "wasn't a great drama" and did not give rise to "constitutional problems".
The debate over medically assisted dying is far from over in Portugal.
"The adoption of this law has been relatively fast compared with other big countries," said Paulo Santos, a member of the pro-euthanasia group Right To Die With Dignity.
He warned a large number of doctors could raise moral objections to carrying out euthanasia, as they had done over abortions in 2007.
"There's a good chance euthanasia will lead to even stronger resistance," he told AFP.
For their part, critics of medically assisted dying regret that the issue has not been put to a referendum and hope opposition deputies will once again ask the constitutional court to look into the bill.
Euthanasia and assisted suicide are only allowed in a handful of countries, including the Benelux nations and Portugal's neighbour, Spain.