א"ר יוחנן משום ר"ש בן יהוצדק:
נימנו וגמרו בעליית בית נתזה בלוד:
כל עבירות שבתורה -
אם אומרין לאדם עבור ואל תהרג,
יעבור ואל יהרג,
חוץ מעבודת כוכבים וגילוי עריות ושפיכות דמים.
ועבודת כוכבים לא?
והא תניא א"ר ישמעאל:
מנין שאם אמרו לו לאדם עבוד עבודת כוכבים ואל תהרג,
מנין שיעבוד ואל יהרג?
ת"ל (ויקרא יח, ה)
[וּשְׁמַרְתֶּ֤ם אֶת־חֻקֹּתַי֙ וְאֶת־מִשְׁפָּטַ֔י אֲשֶׁ֨ר יַעֲשֶׂ֥ה אֹתָ֛ם הָאָדָ֖ם]
וָחַ֣י בָּהֶ֑ם -
ולא שימות בהם.
Rabbi Yoḥanan says in the name of Rabbi Shimon ben Yehotzadak:
The Sages counted the votes of those assembled and concluded in the upper story of the house of Nitza in the city of Lod:
With regard to all other transgressions in the Torah, if a person is told:
Transgress this prohibition and you will not be killed, he may transgress that prohibition and not be killed, because the preserving of his own life overrides all of the Torah’s prohibitions. This is the halakha concerning all prohibitions except for those of idol worship, forbidden sexual relations, and bloodshed. Concerning those prohibitions, one must allow himself to be killed rather than transgress them.
The Gemara asks: And should one not transgress the prohibition of idol worship to save his life?
But isn’t it taught in a baraita: Rabbi Yishmael said:
From where is it derived that if a person is told: Worship idols and you will not be killed, from where is it derived that he should worship the idol and not be killed?
The verse states: “You shall keep My statutes and My judgments, which a person shall do, and he shall live by them” (Leviticus 18:5), thereby teaching that the mitzvot were given to provide life, but they were not given so that one will die due to their observance.