Summary: The Gemara says that a zealot may kill various sinners including one who has relations with a non-Jewess. The sinner may defend himself. But the Rosh writes that bystanders may not kill the zealot and would be considered murderers if they do.
The Mishna in Sanhedrin (9:6) writes that there are three sins for which zealots kill the offender: stealing a service vessel from the temple, cursing God in the name of an idol, having relations with a non-Jewess. Similar treatment is meted out to an impure kohen who performs the Avodah, by the other kohanim.
הַגּוֹנֵב אֶת הַקַּסְוָה וְהַמְקַלֵּל בַּקּוֹסֵם וְהַבּוֹעֵל אֲרַמִּית, קַנָּאִין פּוֹגְעִין בּוֹ. כֹּהֵן שֶׁשִּׁמֵּשׁ בְּטֻמְאָה, אֵין אֶחָיו הַכֹּהֲנִים מְבִיאִין אוֹתוֹ לְבֵית דִּין, אֶלָּא פִרְחֵי כְהֻנָּה מוֹצִיאִין אוֹתוֹ חוּץ לָעֲזָרָה וּמַפְצִיעִין אֶת מֹחוֹ בִּגְזִירִין.
The Gemara Sanhedrin 82a says that Pinchas killing Zimri was an example of a zealot killing one who has relations with a non-Jewess. The Gemara says that had Zimri killed Pinchas he would have been exempt because Pinchas was classified as a “rodef”, and had Zimri ceased his sin and Pinchas still killed him, then Pinchas would have been liable in court for murder (for the exemption of a zealot is only applicable while the sin is being committed; Rashi)
The Gemara there also states that we don’t encourage the zealot.
א''ר חסדא הבא לימלך אין מורין לו איתמר נמי אמר רבה בר בר חנה א''ר יוחנן הבא לימלך אין מורין לו ולא עוד אלא שאם פירש זמרי והרגו פנחס נהרג עליו נהפך זמרי והרגו לפנחס אין נהרג עליו שהרי רודף הוא
The Rosh (9:4) and Ramah (Yad Ramah 82a) rule that only the sinner may kill the zealot. The Rosh adds that anyone else would be considered a murderer for killing the zealot.
Regarding the propriety of this zealotry Rambam comments in Peirush Hamishnayos that if the zealot kills he isn’t punished. This perhaps implies that the actions of the zealot are b'diavad; not optimal. However in Mishne Torah (Issurei Biah 12:4) he writes that the actions of the zealot are commendable.
כָּל הַבּוֹעֵל כּוּתִית בֵּין דֶּרֶךְ חַתְנוּת בֵּין דֶּרֶךְ זְנוּת אִם בְּעָלָהּ בְּפַרְהֶסְיָא וְהוּא שֶׁיִּבְעל לְעֵינֵי עֲשָׂרָה מִיִּשְׂרָאֵל אוֹ יֶתֶר אִם פָּגְעוּ בּוֹ קַנָּאִין וַהֲרָגוּהוּ הֲרֵי אֵלּוּ מְשֻׁבָּחִין וּזְרִיזִין וְדָבָר זֶה הֲלָכָה לְמשֶׁה מִסִּינַי הוּא. רְאָיָה לְדָבָר זֶה מַעֲשֶׂה פִּינְחָס בְּזִמְרִי
Raavad writes (there) that it is only commendable if one warns the sinner first.
כל הבועל עכו''ם וכו'. כתב הראב''ד ז''ל בד''א שהתרו בו ולא פירש אבל לא התרו בו לא אמרינן הרי אלו משובחין עכ''ל
see also discussion here