At the end of the previous parashah, Balak, the text recounts how Moabite and Midianite priestesses sexually perverted many members of the people of Israel through a pagan orgiastic cult dedicated to the Baal Peor deity. On the advice of Balaam, these women were sent to lead Israel astray. Unable to curse Israel, for which he had been hired by Balak, since God transformed his curses into blessings, it occurred to him to destroy Israel by moving the people away from their faith.
A plague was then sent by God who also ordered Moses to execute all those who worshiped the idol. The sentence is transmitted by Moses to the judges who are the ones to implement it.
But one of the chiefs of the tribe of Simeon, Zimri ben Salu, had publicly performed an orgiastic act with Kozbi bat Zur, daughter of one of the chiefs of Midian. Pinchas, the grandson of Aaron, took a spear and executed both of them at the same time. Zimri's act repudiated the values that God had revealed to Israel as the basis of their communal lives. Zimri thus had defied God Godself. Pinchas was zealous about the honor of God.
God awarded Pinchas for his deed by granting him the position of High Priest that would be inherited forever by his descendants and by also granting him a peace pact. However, the sages of the Talmud questioned the propriety of Pinchas’ actions because he had executed Zimri without a death sentence having been legally imposed.
The Jerusalem Talmud, Sanhedrin chapter 9, halacha 7, states that what Pinchas did was not to the liking of the sages and that only the intervention of God stopped the criticism of his conduct. In Sanhedrin 82,a, the wise Rav justified the actions of Pinchas based on a preexisting norm that allowed such conduct, while Shmuel justified his impulsive act by the gravity of the crime that Zimri had committed. Rabbi Yitzchak said that Pinchas had decided to intervene to stop the deadly plague of immorality that was spreading among the people.
Maimonides codified the law (Yad, Isurei Biah, 12: 4-5) that allowed summary action in this case but granted clear rights of self-defense to the victim.
According to the Bible, justice is an essential element in the underpinning of every human society because it is the foundation that sustains the throne of God (Psalm 89:15; 97: 2)