Spain is set to become the fourth country in Europe and the sixth in the world to legalise euthanasia.
Legislation backed by the ruling PSOE party was passed by Spain's parliament on Thursday. It now needs final approval from the Senate to become law but is not expected to face any opposition there.
Once it has been approved by Senate, it is expected to come into effect in the first half of 2021.
The legislation was passed despite strong opposition from religious groups. As the vote was taking place, protesters gathered outside the parliament with placards that read: "Government of death."
The Spanish Evangelical Alliance issued a statement earlier this year saying that the government should help people with "hopelessness and pain", instead of legalising euthanasia.
"The number of patients who consider euthanasia as an option diminishes drastically if the alleviation of pain is facilitated, and human accompaniment and resources to combat hopelessness is offered," it said.
At the moment, Belgium, Luxembourg and the Netherlands are the only European countries where euthanasia is permitted.