Campaigners are hailing it as Spain’s first law on dignity in death.
Terminally-ill patients in Andalucia will be allowed to refuse treatment that artificially prolongs their life.
The landmark legislation won cross-party approval in the autonomous region’s parliament.
Regional Health Official Maria Jesus Montero said: “An honourable life needs an honourable death. This is what the legal regulation tries to fulfil and protect.”
While backing the law on the whole, the conservative Popular Party opposed three of the articles adopted. It believes health professionals should have the right to object to implementing the new law on grounds of conscience.
The legislation applies to public and private hospitals and clinics in Andalucia, including those with religious links.