Bamidbar (Numbers): Pinchas > Ch 25
Israelites commit harlotry with Moabites and worship Baal Peor. G-d commands to hang all leaders and sends a plague on the Israelites.
Israel settled in Shittim, and the people began to commit harlotry with the daughters of the Moabites. They invited the people to the sacrifices of their gods, and the people ate and prostrated themselves to their gods. Israel became attached to Baal Peor, and the anger of the Lord flared against Israel.
The Lord said to Moses, "Take all the leaders of the people and hang them before the Lord, facing the sun, and then the flaring anger of the Lord will be removed from Israel. Moses said to the judges of Israel, "Each of you shall kill the men who became attached to Baal Peor.
Phinehas saves Israelites by killing the guilty one and thus avenging G-d. 24000 people die in the plague.
Then an Israelite man came and brought the Midianite woman to his brethren, before the eyes of Moses and before the eyes of the entire congregation of the children of Israel, while they were weeping at the entrance of the Tent of Meeting. Phinehas the son of Eleazar the son of Aaron the kohen saw this, arose from the congregation, and took a spear in his hand. He went after the Israelite man into the chamber and drove [it through] both of them; the Israelite man, and the woman through her stomach, and the plague ceased from the children of Israel.
Those that died in the plague numbered 24000.
G-d gives Phinehas and his descendants an eternal covenant of kehunah
The Lord spoke to Moses, saying:
Phinehas the son of Eleazar the son of Aaron the kohen has turned My anger away from the children of Israel by his zealously avenging Me among them, so that I did not destroy the children of Israel because of My zeal.
Therefore, say, "I hereby give him My covenant of peace. It shall be for him and for his descendants after him [as] an eternal covenant of kehunah, because he was zealous for his G-d and atoned for the children of Israel."
The name of the Israelite man who was killed, who was slain with the Midianite woman was Zimri the son of Salu, the chieftain of the Simeonite paternal house. And the name of the Midianite woman who was slain was Cozbi the daughter of Zur, a national leader of a paternal house in Midian.
G-d tells Moses to smite the Midianites for their plots of bringing G-d’s wrath on the Israelites
The Lord spoke to Moses saying: Distress the Midianites, and you shall smite them. For they distress you with their plots which they contrived against you in the incident of Peor and in the incident of Cozbi their sister, the daughter of the Midianite chieftain, who was slain on the day of the plague [that had come] because of Peor.