Violating Torah to Save Your Life
From Halachipedia
An overarching principle in the Torah is that we do our utmost to preserve life even at the expense of negating a law of the Torah. There are three major exceptions where it is incumbent upon a person to give up his life in order to follow the halacha. Namely, to avoid murder, Avoda Zara, and illicit relations a person should give up his life rather than violate these critical mitzvot. Surrendering one's life in order to uphold the Torah when it is halachically prescribed is a [Kiddush Hashem]], sanctifying Hashem's name, of the highest order.[1]
The Big Three
- If a person's life is threatened unless he violates murder, Avoda Zara, or illicit relations, he may not violate the law. Rather he should die in fulfillment of the mitzvah of Kiddush Hashem, sanctifying Hashem's name.[2]
- Many rishonim hold that even associated prohibitions to the big three prohibitions one should also give up one's life. In technical terms these are called avizrayhu (Heb. אביזריהו, lit. associated). For example, if one is threatened to give up one's life or hug one of the relatives forbidden to him he would have to give up his life.[3]