25. Kiddush Hashem
Yesodei HaTorah 5:1
All Jews are commanded to sanctify God's great Name, as per Leviticus 22:32, “I shall be sanctified among the children of Israel.” They are likewise warned not to desecrate His Name, as the verse continues, “And they shall not desecrate My holy Name.”
The implication is that if a non-Jew should try to force a Jew to violate one of the Torah's laws under the threat of death, the Jew should violate the law rather than die as per Leviticus 18:5, which says of the mitzvos “that a person shall perform and live by them.” We see that one should live because of the mitzvos, not die because of them. If a person chooses to die rather than violate a commandment, he is considered responsible for the loss of his own life.
Yesodei HaTorah 5:2
This is the case with all mitzvos except for idolatry, forbidden sexual relations (incest, adultery, etc.) and murder. When it comes to these three sins, one should give up his life rather than violate them.
All this is the case when the non-Jew wants the Jew to violate a commandment because it is somehow for his own benefit, such as if the non-Jew wants to force the Jew to perform labor for him on Shabbos. However, if his intention is simply to force the Jew to violate God’s law, then if he is alone - i.e., there are not ten other Jews present - he should violate the commandment in question rather than sacrifice his life. However, if the non-Jew is trying to compel the Jew to violate a commandment in the presence of ten Jews, then he should give up his life rather than submit. This is the case even if the non-Jew wants him to violate just one mitzvah.