Parliament voted through a law legalising euthanasia on Thursday making Spain one of few nations to allow terminally-ill or gravely-injured patients to end their own suffering.
A priority for Socialist Prime Minister Pedro Sanchez's government, the law was drafted following public pressure generated by several high-profile cases, notably that of Ramon Sampedro whose plight was immortalised in the Oscar-winning 2004 film "The Sea Inside".
The vote, which passed by 202 in favour, 141 against and two abstentions in the 350-seat chamber, makes Spain the fourth European nation to decriminalise assisted suicide, alongside the Netherlands, Belgium and Luxembourg.
Although Portugal's parliament passed a similar law in January, it was blocked this week by the Constitutional Court.
"Today we have become a country that is more humane, fairer and freer. The euthanasia law, widely demanded by society, has finally become a reality," Sanchez tweeted just minutes after the vote.
"Thanks to all the people who have fought tirelessly for the right to die with dignity to be recognised in Spain."
The Spanish legislation will permit euthanasia in which medical staff intentionally end a life to relieve suffering, and assisted suicide in which it is the patient who carries out the procedure.
Various other countries permit assisted suicide as well as "passive euthanasia" in which life-saving medical treatment is halted.
Speaking to AFP, Ramona Maneiro, a friend of Sampedro's who was arrested for helping him die but not prosecuted for lack of evidence, hailed the move as a victory "for those who can benefit from it" and "for Ramon".
Backed by left-wing and centrist parties, the legislation allows anyone with a "serious or incurable illness" or a "chronic or incapacitating" condition to request help dying, thereby avoiding "intolerable suffering".
But the patient must be a Spanish national or a legal resident and "fully aware and conscious" when they make the request, which has to be submitted twice in writing, 15 days apart.
A doctor can reject the request if the requirements have not been met. It must be approved by a second medic and by an evaluation body.
Any medic can withdraw on grounds of "conscience" from taking part in the procedure that will be available via Spain's national health service.
Outside parliament, right-to-die campaigners were jubilant.
"From today, we Spaniards will be able to sleep easier, feeling a bit more free," said Danel Aser Lorente, a 45-year-old film lecturer whose mum had Alzheimers and was denied the right to end her own life.
"Today is a very positive day... also one of anger because we fought for my mum's wishes to be respected, but she died suffering," he told AFP.
Nearby, holding a placard reading "Mission accomplished" was Asun Gomez Bueno, 54, whose husband died with primary progressive multiple sclerosis, which has almost no prospect of remission.
"It has been a four-year struggle in which I was called a murderer because I wanted to help my husband to stop suffering," she said.
'Form of murder'
But the move has drawn stark opposition from the Catholic Church, with Spain's leading bishops denouncing euthanasia as "a form of murder since it involves one man causing the death of another".
Opponents of the law also staged a counter-demonstration with around 100 people in black hats rallying outside parliament to a sombre drumbeat.
"Let's not forget that the first to practise euthanasia on the weakest ended up carrying it out as part of the final solution in Nazi Germany," said Polonia Castellanos, spokeswoman for the Spanish Association of Christian Lawyers.
"Those who are suffering.. are being pushed to take the quickest solution, which is death," she told reporters, saying the association would appeal to the Constitutional Court.
Euthanasia first entered the public debate in Spain in the mid-1980s and took on greater urgency over the case of Sampedro, a tetraplegic who fought an unsuccessful 30-year court battle to end his own life, eventually dying with a friend's help in 1998.
More recently, pensioner Angel Hernandez was arrested in 2019 and is awaiting trial for helping his wife end her life after decades of suffering from multiple sclerosis.
By Diego Urdaneta