Numbers 22:2 to 25:9, Micah 5:6 to 6:8
Verse 23:21 is odd. "No one has seen iniquity (avon) in Ya'akov or perceived trouble in Israel." Apparently God's quick punishments upon his people meant that Bilaam was powerless to add further punishments.
Verse 25:2 says that "joining yourself" to Baal-Peor included eating from aniamls sacrificed to that idol. Psalm 106:28 calls these "the sacrifices of the dead".
In verse 25:4 God tells Moshe that people should be hoka—punished by exposure in stocks or hanging—in public (in full daylight, see also 2nd Samuel 12:12). Which people? Since Moshe, in the next verse, has judges (shofteem) kill those who had joined themselves to Baal-Peor it is most sensible to parse verse 25:4 as "take the leaders of the people and [have these leaders] hoka them [the idolaters]..." rather than "take the leaders of the people and [you alone] hoka them [the leaders]..."
Deuteronomy 1:16 (and the verb use of Leviticus 19) suggests these judges are the leaders Yitro suggested as opposed to the census's leaders of the tribes.
Note that Bilaam is killed by the Israelites in Numbers 31:8.
One traditional story tells of Moav and Midian, traditionally enemies, temporarily making peace to keep the Israelites at bay. A paraphrase:
Balak, King of Moav, was so frightened by the Israelite's supernatural victories over Sichon and Og that feard for his own life. Thus he calls himself "Balak, son of Zipor" (a mortal man) instead of "Balak, King of Moav" (representative of a nation).
He knew Moshe grew up in Midian, and so made peace with the Midianites and asked their elders how to defeat Moshe. The elders replied, "Moshe has power through his mouth when he prays." Then Balak thought, "I know a man, Bilaam, who also has power in his mouth. He can oppose Moshe."
Balak was too aggressive, and this lead to trouble. If he had asked Balaam to bless Moav, then Moav could have propsered. But Balak asked for Israel to be cursed and thus received no assistance.
Verse 22:7 says that Balak's representatives went to Bilaam oo'k'sameem b'yadam ("with divinations in their hands"). They took the tools for divination with them, so Bilaam would not be able to say he could not do what they asked.
The Or ha'Chayim explains the contradiction in verses 22:12 and 22:20 (God forbids and then allows Bilaam to go) by teaching that God's initial refusal emphasized that Bilaam must obey God, and God's later permission proved God was not afraid of Bilaam's desire to attempt to curse Israel.
Most commentators say Bilaam's sin was leaving for Moav too soon, and with too much enthusiasm ("rushed" in many translations of verse 22:32). God had told Bilaam that he would be going, but not that he should depart first thing in the morning.
In verses 24:3 and 24:15 Bilaam calls himself a gever, a warrior. But he is not a warrior, for he carries no sword and is not brave. This word is used because Bilaam was shouting loudly, for God not only forced him to bless Israel but to do so very loudly. R' Yehoshua ben Levi taught that Bilaam's voice could be heard for seventy miles. R' Eliezer HaKapar taught that miraculously Bilaam's voice could be heard across the earth.
Tradition interprets verse 23:21 ("No one has seen guilt in Ya'akov or perceived perversity in Israel") by looking back to the Flood, which tradition says happened becasue of the two sins of idolatry and adultery. Since Israel had been given the ashes of the red cow as both atonement for the sin of the golden calf and to deal with adultery, then Israel was protected from the kind of judgment that (like the Flood) exterminates. When Bilaam explained this then Balak knew to defeat Israel he would have to tempt them to sin in adultery and idolatry, which is what he did after Bilaam departed.
Verse 23:23 says kee lo nachash b'Ya'akov ("for there is no magic in Ya'akov"). Only those who practice divination are succeptible to it; for this reason God outlawed it in Torah.
The Ba'al ha'Turim notes that when Bilaam pronounces (about Israel) "Cursed be all who curse you" that Balak realizes his goal of cursing Israel is pointless—even if it succeeds it fails—and immediately tries to send Bilaam home.
Verse 31:16 says that it was Balaam's idea for the Moavite women to seduce the Israelites at Peor.
The worshipping of the golden calf caused only 3,000 to die, for the people were idolatrous but did not mean to be, since they claimed the calf represented Adonai. The worshipping of Baal-Peor, intentially real idolatry, caused 24,000 to die in this incident, and countless others later in scripture.
Verses 25:7-8 contain as Hebrew play on words. "Taking a spear in hand he came after the man of Israel to hakoobah (his private place (tent)) and thrust through them both, the man of Israel and the woman, kavatah (in the private parts)."