Bilaam was the greatest prophet to the non-Jewish nations at his time. This section of Bilaam’s prophecy from BaMidbar 24:17 says:
אראנו ולא עתה אשורנו ולא קרוב דרך כוכב מיעקב וקם שבט מישראל ומחץ פאתי מואב וקרקר כל בני שת
The opening words of his prophecy are about the (future, from his perspective then,) final redemption and establish that there are two general sequential stages to the process, one that happens first (אראנו ולא עתה) followed later by the second stage (אשורנו ולא קרוב).
This is in keeping with the teaching of Rabbi Moshe Chaim Luzzato in his מאמר הגאולה, second chapter. The earlier stage is called the Pekidah פקידה and the later stage is called the Zachirah זכירה.
In continuation of this sequential pattern, the first half of the language of Bilaam’s prophecy is a direct reference to the two part prophetic dream that was said by Yosef HaTzaddik when he was a seventeen year old boy prior to his being sold into slavery by his brothers. 17 which is the gematria of the word, good טוב, and continuing the numerical sequence from 17 leads to 18, which is the gematria, life חי and which in small sum gematria (מספר קטן) is משיח (Moshiach). Like it says in Ezekiel 14:20-23:
חי אני נאום אדני יהוה גו׳
The second half of Yosef’s two part dream is recorded in Bereshit 37:9-10, which says:
ויחלם עוד חלום אחר ויספר אתו לאחיו ויאמר הנה חלמתי חלום עוד והנה השמש
והירח ואחד עשר כוכבים משתחוים לי
ויספר אל אביו ואל אחיו ויגער בו אביו ויאמר לו מה החלום הזה אשר חלמת
הבוא נבוא אני ואמך ואחיך להשתחות לך ארצה
In the original prophecy of Yosef, it connects the eleven stars with the eleven brothers of Yosef, who were also sons of Yaacov.
This reference to the number eleven is reminiscent of the eleven ingredients of the incense that was burned by the Kohanim in the Temple service each day. This incense was burned by Aharon the High Priest to stop the plague from the Angel of Death which was killing the Jewish people at a time of great public rejection of G-d’s commandments like is seen in BaMidbar 17:11-14.
It is emphasized in the Torah that this incense is only valid when every single one of its ingredients are included together and in their proper proportion. Failure to include all the ingredients together properly obligates the one attempting this improper mixture to death. This is a sign of the importance and meaning of Jewish unity and is also the unique sign of Kingship connected with Moshiach ben Yosef.
That the 11 sons, together with their Mother and Father, would bow to Yosef at some point in the future is a sign of Yosef’s future Kingship, that he was משנה למלך like it says in Bereshit 41:41-44.
Their bowing is a sign that they are loyal, willing and faithful subjects and servants to the King.
An important detail that should be noted in order to understand all of Yosef’s second dream is its context with the first prophetic dream that he had, which preceded it and is mentioned in Bereshit 37:5-8.
That in the first dream, both Yosef and his eleven brothers are included in the same dream category. In the first dream, they are all bundled sheaves of grain.
The bundled sheaves illustrate that unity first begins in small, similar groups, like husband and wife, family or tribal groups. Then those smaller groups find unity of purpose with each other, cooperating and working for the common good which leads to an increase in and diversification of life.
This increase and diversification of life is the first commandment of G-d in the Torah, to be fruitful and multiply (Bereshit 1:22), meaning to reproduce the species, increase their numbers and diversify, forming variations (like the Hebrew expression סגולה has a connotation of adaptability or flexibility מסוגל) within the species. (That diversity within a species, meaning successfully adapting to multiple environments, adds resilience and increased vitality to that species.) This commandment applies to all living things. Accepting and fulfilling it is the revelation of G-d’s Kingship as it pertains to Yosef (who like Moshe Rabbeinu, earns and attains the Chaya aspect of soul חיה See the description in Sefer Ohr HaChamah of Zohar, parshat Shemot 7b).
This essential commandment for life was then repeated a second time specifically to the beginning of the human species (Bereshit 1:26-28), who are to serve as the representative of the King משנה למלך and behave similar to G-d above (דומה לעליון) in preserving and protecting (Bereshit 2:15) לעבדה ולשמרה themselves and all life, and consequently meaning all of His creations. These are the two aspects or signs of Kingship.
In Yosef’s second dream, his eleven brothers are eleven stars. So too, from the context of his first dreams, Yosef is also in the category of a star like his brothers.
The significance of this is that in the context of Yosef’s dreams, the star that arises from Yaacov (דרך כוכב מיעקב) is associated with Yosef, meaning Moshiach ben Yosef.
Bilaam’s prophecy also indicates that one of those eleven would also be associated with the scepter of Kingship, (וקם שבט מישראל) the sign of a second aspect of Kingship.
This scepter, the second sign of Kingship is reminiscent of the Lulav (which is built upon the foundation of Jewish unity like the incense, because the commandment of Lulav requires the unity of all 4 species, representing all types of Jews, religiously observant and otherwise, being held together) but which additionally is taken up by Jews on Sukkot and waved in all four directions of the compass, south, north, east and west, above and below. This additional dimension is the second aspect of Malchut, which is a sign revealing G-d’s Kingship over the whole world, meaning the whole universe and at all times, past, present and future. This second aspect pertains to Moshiach ben David, or as Rambam describes, Moshiach with certainty.
This idea, that there are two distinct aspects to Kingship, that from Yosef (Moshiach ben Yosef) and the other from Yehudah (Moshiach ben David) is also what is expressed by Rambam in chapter 11 of the Mishneh Torah, Laws of Kings and their Wars, Halacha 4 in the context of Presumed to be Moshiach and Moshiach with Certainty.
In regard to the terminology used by Rambam, meaning his particular and distinct categorizations, it should be emphasized that these changes in nomenclature are innovations by Rambam which were not used prior to his time. The traditional teaching on the subject of Moshiach uses only the terms and names that pertain to Moshiach ben Yosef, also called “Ephraim, My Righteous Moshiach” (like Ephraim was the son of Yosef HaTzaddik in Egypt) and Moshiach ben David.
The language of the second half of that original prophecy by Bilaam was established by the prophetic blessing by Yaacov. Yaacov, who after so many years of sadness would again be called Yisroel in Egypt with the return of his son, Yosef to him.
That to receive prophecy requires the Prophet to be in a state of joy. So when Yosef was sold into slavery and went missing, Yisroel reverted to his non-prophetic name of Yaacov because of his sadness.
In his last 17 years, when his son Yosef had been returned to him from his captivity, Yaacov’s sadness was transformed into joy and his prophetic name of Yisroel was renewed.
At the end of Yaacov’s life, he assembled all his sons to give each of them a unique, prophetic blessing. The blessing for Yehudah appears in parshat VaYechi, Bereshit 49:8-12, which says:
יְהוּדָ֗ה אַתָּה֙ יוֹד֣וּךָ אַחֶ֔יךָ יָדְךָ֖ בְּעֹ֣רֶף אֹיְבֶ֑יךָ יִשְׁתַּחֲו֥וּ לְךָ֖ בְּנֵ֥י אָבִֽיךָ׃
גּ֤וּר אַרְיֵה֙ יְהוּדָ֔ה מִטֶּ֖רֶף בְּנִ֣י עָלִ֑יתָ כָּרַ֨ע רָבַ֧ץ כְּאַרְיֵ֛ה וּכְלָבִ֖יא מִ֥י יְקִימֶֽנּוּ׃
לֹֽא־יָס֥וּר שֵׁ֙בֶט֙ מִֽיהוּדָ֔ה וּמְחֹקֵ֖ק מִבֵּ֣ין רַגְלָ֑יו עַ֚ד כִּֽי־יָבֹ֣א שִׁילֹ֔ה וְל֖וֹ יִקְּהַ֥ת עַמִּֽים׃
אֹסְרִ֤י לַגֶּ֙פֶן֙ עִירֹ֔ה וְלַשֹּׂרֵקָ֖ה בְּנִ֣י אֲתֹנ֑וֹ כִּבֵּ֤ס בַּיַּ֙יִן֙ לְבֻשׁ֔וֹ וּבְדַם־עֲנָבִ֖ים סוּתֹֽה׃
חַכְלִילִ֥י עֵינַ֖יִם מִיָּ֑יִן וּלְבֶן־שִׁנַּ֖יִם מֵחָלָֽב׃
It is here that Kingship is established for Yehudah and his tribe with the same sign that indicated Kingship for Yosef. That Yaacov states his brothers would bow to him. This sign is referring to Kingship like Yosef's in Egypt, meaning Moshiach ben Yosef.
It should be noted that immediately after Yaacov mentions the sign of bowing, it applies three different terms for the three stages in the maturation and development of a lion, that of a cub גור אריה, that of a mature adult אריה, and when it becomes the leader of the pride and King לביא. This term refers to when the lion develops its full mane, much like a crown surrounding its head.
This last term combines two aspects, לב, that the King is called the Heart, and יא, like the 11 other sons of Yaacov and the 11 ingredients in the incense. That the King is the heart of the whole nation, like Rambam says in Mishneh Torah, Laws of Kings, chapter 3, Law 6.
It is also in that blessing that mention of the Scepter of Kingship is made (לֹֽא־יָס֥וּר שֵׁ֙בֶט֙ מִֽיהוּדָ֔ה). This second sign of Kingship, different from the sign of Kingship of Yosef, refers to Moshiach ben David who, like King David, his ancestor will be descended from the tribe of Yehudah.
This emphasizes that the qualities of Kingship found in Moshiach ben Yosef and Moshiach ben David are ultimately manifest in the same single individual. They arise from Yaacov and Yisroel who are one and the same person (דרך כוכב מיעקב וקם שבט מישראל). This follows the prophecy of Yechezkel, like is found in chapter 37:19, which says:
דבר אלהם כה אמר אדני יהוה הנה אני לקח את עץ יוסף אשר ביד אפרים ושבטי
ישראל חבריו ונתתי אותם עליו את עץ יהודה ועשיתם לעץ אחד והיו אחד בידי
That this unification of these two qualities of Kingship into the single individual is done specifically by the hand of G-d, which is a reference to resurrection like is found in the prophecy of Isaiah 60:21 which says:
וְעַמֵּךְ֙ כֻּלָּ֣ם צַדִּיקִ֔ים לְעוֹלָ֖ם יִ֣ירְשׁוּ אָ֑רֶץ נֵ֧צֶר מטעו [מַטָּעַ֛י] מַעֲשֵׂ֥ה יָדַ֖י לְהִתְפָּאֵֽר׃
The prophetic blessing of Yaacov to Yehudah also emphasizes that this second type of Kingship will stay with his descendants until the coming of Shilo.
That the phrase, כי יבא שילה is gematria 388 which refers to the word אלבשנה from Shir HaShirim 5:3, which says:
פָּשַׁ֙טְתִּי֙ אֶת־כֻּתׇּנְתִּ֔י אֵיכָ֖כָה אֶלְבָּשֶׁ֑נָּה רָחַ֥צְתִּי אֶת־רַגְלַ֖י אֵיכָ֥כָה אֲטַנְּפֵֽם׃
I have removed my coat, how shall I put it (back) on?
The coat is a reference to the special coat of many colors worn by Yosef and which was given to him by his father Yaacov like is mentioned in Bereshit 37:3. The removal of this garment, mentioned in Shir HaShirim is referring to the prophetic requirement that Moshiach ben Yosef will die. He will remove his garment, meaning his body, from his soul.
This incredible statement follows the traditional teaching brought by Rabbi Hoshaia the Great, who was also known as Rabbi Oshaya, (the Father of the Mishnah) that is found in Shemot Rabbah, chapter 35 which says:
אָמַר רַבִּי הוֹשְׁעְיָא, עַל שׁוּם שֶׁהוּא עוֹמֵד לְמַשְׁכֵּן, שֶׁאִם נִתְחַיְבוּ שׂוֹנְאֵיהֶם שֶׁל יִשְׂרָאֵל כְּלָיָה, יְהֵא מִתְמַשְׁכֵּן עֲלֵיהֶן. אָמַר משֶׁה לִפְנֵי הַקָּדוֹשׁ בָּרוּךְ הוּא וַהֲלוֹא עֲתִידִים הֵם שֶׁלֹא יִהְיֶה לָהֶם לֹא מִשְׁכָּן וְלֹא מִקְדָּשׁ, וּמַה תְּהֵא עֲלֵיהֶם, אָמַר הַקָּדוֹשׁ בָּרוּךְ הוּא אֲנִי נוֹטֵל מֵהֶם צַדִּיק אֶחָד וּמְמַשְׁכְּנוֹ בַּעֲדָם, וּמְכַפֵּר אֲנִי עֲלֵיהֶם עַל כָּל עֲווֹנוֹתֵיהֶם, וְכֵן הוּא אוֹמֵר (איכה ב, ד): וַיַּהֲרֹג כֹּל מַחֲמַדֵּי עָיִן.
The posuk from Eicha 2:4 and also Eicha 3:12, which Rabbi Hoshaia brings as support for his teaching parallels the language from the prophecy of Bilaam (BaMidbar 24:17), דרך כוכב מיעקב גו׳ which is actually referring to Moshiach ben Yosef who is destined to either be murdered or simply die in payment of whatever debt the nation of Israel has accumulated over time. That משכון is in the sense of someone who acquires the debt owed by others like is used in Mishnah Bava Metzia 6:7. This debt transfer is possible because the King represents the whole nation, meaning the concept of צבור. (That בת-ציון meaning ציון mentioned in Eicha 2:4 is gematria Yosef יוסף, meaning Moshiach ben Yosef.) That his death serves as an atonement for the transgressions of everyone.
The continuation of the posuk , “וקם שבט מישראל” refers to Moshiach ben David.
Shlomo HaMelech asks the question, once the garment is removed, how is one able to put it back on? This is alluding to the resurrection of the dead, meaning that Moshiach will at some point die and ultimately be resurrected. This follows the text found in Sukkah 52b, that among the first 15 to be resurrected will be Eliyahu the Prophet, Moshiach ben David and (all those who had been in previous generations) Moshiach ben Yosef.
So the language of Bilaam’s prophecy is confirming and restating the prophetic blessing of Yisroel.