Judaism has a complex relationship with the ideal of martyrdom.
Reprinted from The Jewish Religion: A Companion, published by Oxford University Press.
Martyrdom, in Hebrew Kiddush Ha-Shem ('Sanctification of the Divine Name'), is defined as giving up life rather than being false to the Jewish religion.
There is considerable discussion in the Talmudic literature on when martyrdom is demanded of the Jew and when it is not, much of it purely academic but some of it severely practical.
The Mishnah (Berakhot9:5) interprets the command to love God 'with all thy soul' (Deuteronomy 6:5) to mean 'with all thy life', that is, love Him even at the cost of your very life. But against this is the verse (Leviticus 18:5): 'by the pursuit of which man shall live', understood in the tradition to mean live and not die, implying that martyrdom is not demanded in pursuit of the precepts of the Torah.
Dying for What?
The resolution of this apparent contradiction is that a Jew is required to give his life for some of precepts but not for others. The question is then where to draw the line.
Generally from the Talmudic discussions (e.g. Sanhedrin 74a) the rule emerges that all the other precepts of the Torah can be set aside rather than martyrdom be suffered, but a Jew is required to give up life rather than offend against three basic commandments. These are: idolatry, the forbidden sexual relations recorded in the book of Leviticus, and murder.
Following the further details in the Talmudic discussion, Maimonides (Yesodey Ha-Torah, 5.1-9) rules that a Jew may transgress the precepts of the Torah in order to save his life but that this does not apply to the three offences nor does it apply where the intention of heathens is to compel a Jew to commit an offence in order to demonstrate his disloyalty to the Jewish religion.
Similarly, where there is a government decree against Jewish observance the Jew is obliged to suffer martyrdom rather than transgress a 'light precept' even in private. Where martyrdom is not demanded it is forbidden for a Jew to suffer martyrdom, according to Maimonides, and if he does he is guilty of the offence of suicide.
Obviously the above discussions are from the purely legal point of view. It is hard to imagine that in the actual situations in which Jews were called upon to give their lives for their religion they looked up the rules in the Talmud and the Codes.
In Jewish History
History records many examples of Jewish martyrdom in which the martyrs offered up their lives regardless of whether the law required them to do so. The converse is also true, that Jews whom the law required to be martyrs failed to be strong enough in their loyalty to their faith.