Article 156 [source]

Spanish Criminal Code
English translation

Notwithstanding the provisions of the preceding article, valid, free, conscious and expressly given consent exempts from criminal liability in cases of organ transplantation carried out in accordance with the provisions of the law, sterilizations and transsexual surgery performed by a medical professional, unless the consent has been obtained vitiated, or through a price or reward, or the grantor is a minor or absolutely lacks the capacity to give it, in which case the consent given by them or by their legal representatives will not be valid.