אלהם ואמרת אהרן בני הכהנים אל אמר משה אל ‘ה ויאמר” (א כא) “בעמיו יטמא לא לנפש
In the piyut of Eileh Ezkerah, said in Mussaf of Yom Kippur, which describes the killing of the ten harugei malchus, it says that when the head of the holy Tanna Rabban Shimon ben Gamliel Hanassi was cut, “Rav Yishmael took him and screamed about him in a bitter voice that sounded like a shofar: ay halashon hamemaheres lehoros b’imrei shefer, v’eich atah locheches es ha’afar, where is the tongue that hastened to give instructions...and how is it now licking the dust of the earth.”
This heartrending scene is also mentioned in the lamentation of Arzei Halevanon said on Tisha B’Av: “He took his head and put it his knees... He put his eyes on his eyes and his mouth on his mouth in absolute love. He answered and said, a mouth that was overpowering in Torah has suddenly been sentenced to death from its severe sin.”
And the question is asked: Wasn’t Rav Yishmael a Kohein Gadol? How did he make himself tamei with tumas meis when it was not necessary?
Harav Pinchas Horowtiz, the Baal Hafla’ah, answered: The Rema rules (Yoreh Deah 373 7) that when the Kohein Gadol becomes tamei lemeis for a first degree relative he is allowed to also become impure for other dead people as well, because it does not add any further tumah to his existing impurity. In light of this we can say that when Rabbi Shimon was killed, Rabbi Yishmael was with him under the same roof. And because he was already rendered impure in the tent of the dead, no additional impurity was added when he took Rabbi Shimon’s head, and therefore, there was no issur involved. (Panim Yafos Parashas Chukas)
The Minchas Elazar further added: Chazal say (Yerushalmi Brachos 3 1) that when a Nasi passes away, it is permissible for Kohanim to become impure for him, because it showed respect to the Nasi that everyone should be involved in him. Because Rabbi Shimon ben Gamliel was the Nasi, it was permissible for Rabbi Yishmael to become impure for him. (Divrei Torah 9th Edition, 70)
