By Avner Friedmann
This parshah tells of the war between Israel and Midian. It was not a conventional war, but rather a unique spiritual battle between the forces of good and the forces of evil, such as was never seen before or afterwards, and it posed great danger to Israel.
The forces of evil were lead by Balak and Bilaam. They had united their powers to destroy the Jewish people and prevent them from entering the Land of Israel. The spiritual nature of the war required bringing out the secret arsenal of the Jewish people. The warriors were a select group of righteous individuals, clean of all sins; only a thousand from each tribe. The chief commander of the forces of good was Pinchas Ben Elazar HaKohen, who came equipped with the “Sacred Vessels and the Trumpets for sounding, in his hand.” Rashi states that the sacred vessels were the Ark of the Covenant which contained the Tablets and the High Priest’s Head Band which had the words “Holy to Hashem” engraved upon it. He also brought the High Priest’s Breast Plate, so that the Urim V’Tumim could answer questions that arose in the battlefield.
For each thousand men at physical battle front, there was a spiritual backup force of a thousand men learning Torah and praying to HaShem; hence the repetition in the verse, “A thousand from a tribe, a thousand from a tribe.” With the power of the Torah on their side, they went to battle against the huge Midianite army.
Rashi states that Bilaam went to Midian (on his way back home to Aram) to pick up his payment for the advice he had given Balak to entice Jewish men to sexual debauchery, resulting in the deaths of twenty four thousand Israelites. They paid him in full as promised.
The holy Zohar writes that as Bilaam left with his reward, he got caught up in the war and was met by Pinchas and his men. Seeing Pinchas, Bilaam was frightened for his life. Being a Wizard who was adept in black magic, Bilaam pronounced names of impure forces and flew into the air. The five kings of Midian also did so. Pinchas then displayed the golden Head Band toward them and the five kings fell to their death upon the slain troops, as it is written, “They killed the Midianite kings upon those they had slain.” 
Midian suffered a crushing defeat at the hands of Israel. All their males were killed, as commanded by God, while on the Israelite side there were no casualties, as Scripture states, “And not a man of us is missing.”
The fate of Bilaam, however, was different. The Zohar continues: Seeing Bilaam flying, Pinchas sought someone to fly after him and bring him down alive. Tzaliah, of the tribe of Dan volunteered. Equipped with a Holy Name with which to cancel the power of Bilaam, he took off after him. When Bilaam saw Tzalia he managed to deceive him and disappeared in the air. Tzalia feared being harmed by the impure forces. Pinchas, with the power of the High Priest’s Head Plate, helped him from the ground, and Tzaliah saw Bilaam again. He then caught Bilaam and brought him down before Pinchas.
Pinchas instructed Tzaliah to kill Bilaam, not by using Holy Names, but with Bilaam’s own sword. Pinchas did not want Bilaam to die through the mentioning of a Holy Name, so as not to have his soul be included on any level of holiness that dwells with the Holy Names of Hashem. Targum Yonatan states that Bilaam begged Pinchas not to kill him and swore never to curse the Jewish people, but it was too late. Tzaliah slew Bilaam with Bilaam’s own sword, as the verse states: “And Bilaam son of Beor they killed with the sword.”
Bilaam had previously said: “May my soul die the death of the upright, and may my end be like his (Israel).” His wish was to die as a holy man and inherit Gan Eden. This took enormous “Chutzpa” befitting a person as arrogant and greedy as Bilaam. He wanted to live a life of impurity and evil and yet expected the rewards of the righteous.
The Zohar concludes: This is the way of the “Other Side”. Whoever follows its footsteps should expect to eventually be taken by it, along with the hard judgment associated with it. Bilaam was never buried and his bones were left to rot.
May HaShem utterly destroy His enemies, the enemies of Israel, about whom it states in Psalms,  “His mouth is full of Allah, lies and malice. Under his tongue are mischief and iniquity. He lurks in ambush in open cities and murders the innocent in hidden places. His eyes search out for the helpless.” And as Scripture continues there, “(HaShem) break the power of the wicked! If You search for the evil of the wicked, will You not find? HaShem is the King of the world, the Goyim will perish from His land.”
 Ohr Hachaim, Bamidbar 31:3-5.
 Bamidbar 31:6.
 Targum Yonatan.
 Balak 193b-195a.
 31:8. Also see Rashi on 31:6.
 Balak 23:10.
 Ramban, Bamidbar 23:10.
 Psalms 10:7-9.
 Psalms 10:15-16.