"Like streams stretched out (kinḥalim nittayu)." From his blessings you can know what was in his heart to curse. Concerning this the verse says, "But the LORD your God turned the curse into a blessing for you" (Deuteronomy 23:6). He wished to say that they should [not] have houses of study to establish things permanently, but [should be] like streams: just as streams sometimes flow and sometimes do not flow but are dry, the Holy Spirit answered, "stretched out" — that they flow at all times. He wished to say "like gardens," which are sometimes moist and sometimes dry, but the Holy One, blessed be He, put in his mouth "by a river," that they are moist at all times. He wished to say "like tents of spices," for these are sometimes moist and sometimes dry, for when they are moist their fragrance spreads, and when they are dry their fragrance is lost; therefore the Holy Spirit said "the LORD planted," that they are as on the day the LORD planted them, when they are moist. He wished to say "like cedars," which have no roots, and when they are dry the wind comes and uproots them; but the Holy One, blessed be He, put in his mouth and said "by the water," whose roots are deep. He wished to say that they should not have a king son of a king; [but] against his will he said, "Water shall flow from his buckets" (Numbers 24:7), that they should have a king son of a king. He wished to say that they should not rule over another kingdom, and the Holy One, blessed be He, put in his mouth and said, "and his seed shall be in many waters." He wished to say that they should be a lowly nation and fall by the hand of Amalek; the Holy One, blessed be He, [arranged it] so that he should say, "and his king shall be higher than Agag" — and this was Saul, who slew every city of Amalek and placed under the ban Agag king of Amalek. "And his kingdom shall be exalted" — forever, that his kingdom should be prolonged. Another interpretation: "streams stretched out" — these are the heavens, as it is said, "and stretched them out like a tent to dwell in" (Isaiah 40:22), to say that Israel shall endure as the heavens endure, as it is written, "to plant the heavens and to lay the foundations of the earth, and to say to Zion, You are My people" (Isaiah 51:16). "Like cedars by the water" — as you say, "like a cedar in Lebanon he shall grow" (Psalms 92:13). Another interpretation: "I will set in the wilderness a cedar" (Isaiah 41:19) — this is Jerusalem, which was made like a wilderness.
How Balaam's Curse Became Israel's Blessing
Midrash Aggadah, Numbers 24:6
כנחלים נטיו. מברכותיו אתה יכול לידע מה הי' בלבו לקלל, ועל זה אמר הפסוק ויהפוך ה' אלהיך את הקללה לברכה (דברים כג ו), ביקש לומר [שלא] יהיו להם בתי מדרשות לקבוע קבועים אלא כנחלים, מה [נחלים] פעמם מושכים ופעמים אינם מושכים אלא חרבים, ענתה רוח הקודש נטוי שמושכים בכל עת. ביקש לומר כגנות, שפעמים הם לחים ופעמים הם יבישים, והקב"ה שם בפיו עלי נהר, שבכל עת הם לחים. ביקש לומר כאהלים של בשמים, כי פעמים לחים ופעמים יבישים שבשעה שהם לחים ריחם נודף וכשהם יבישים ריחם נאבד, לכך אמר רוח הקדש נטע ה', שהם כיום שנטע ה' אותם והם לחים. ביקש לומר כארזים שאין להם עיקרין, וכשהם יבשים הרוח בא ועוקרן, והקב"ה שם על פיו ואמר עלי מים ששרשם עמוקין. ביקש לומר שלא יהא להם מלך בן מלך, אמר בעל כרחו יזל מים מדליו, שיהי' להם מלך בן מלך. ביקש לומר שלא ישלוט במלכות אחרת, ושם הקב"ה בפיו ואמר וזרעו במים רבים. ביקש לומר שיהיו אומר שפלה ויפלו ביד עמלק, אמר לו הקב"ה כדי שיאמר וירום מאגג מלכו. וזה הי' שאול שהרג כל עיר עמלק והחרים אגג מלך עמלק: ותנשא מלכותו. לעדי עד שתמשך מלכותו: ד"א נחלים נטיו. אלו השמים שנאמר וימתחם כאהל לשבת (ישעיה מ' כ"ב), לומר שיהיו קיימים ישראל כמו שהשמים קיימים, הדא הוא דכתיב לנטע שמים וליסד ארץ ולאמר לציון עמי אתה (שם נ"א ט"ז): כארזים עלי מים. כמה דתימר כארז בלבנון ישגה (תהלים צ"ב י"ג): ד"א אתן במדבר ארז (ישעיה מ"א י"ט), זו ירושלים שנעשית כמדבר: