G‑d, your G‑d, would not listen to Bilam, but ... transformed the curse into a blessing for you, because G‑d, your G‑d, loves you.”

-Ki Teitzei 23:6

The essential prophecy of Bilam, the prophet of the nations of the world, deals with the ultimate downfall of the nations and Israel’s victory over them (see Balak 24:17ff., and the commentaries there).

Just as Bilam used all of his special ability (his prophetic power) to bless Israel, so, in the future the nations of the world will use their energy to help Israel. Thus it is written: “Kings will be your foster-fathers and their queens your nursing mothers” (Isaiah 49:23).

In this verse of our parshah, therefore, there is an allusion to the change from golah (the galut, exile) to ge’ulah (redemption), the transformation of the solemn days of fasting and mourning into days of “joy and gladness and cheerful festivals” (Zechariah 8:19).