>>> Jewish tradition speaks of two redeemers, each one called Mashiach. Both are involved in ushering in the Messianic era. They are
Mashiach ben David and
Mashiach ben Yossef.
The term Mashiach unqualified always refers to Mashiach ben David (Mashiach the descendant of David) of the tribe of Judah. He is the actual (final) redeemer who shall rule in the Messianic age. All that was said in our text relates to him.
Mashiach ben Yossef (Mashiach the descendant of Joseph) of the tribe of Ephraim (son of Joseph), is also referred to as Mashiach ben Ephrayim, Mashiach the descendant of Ephraim. He will come first, before the final redeemer, and later will serve as his viceroy.
The essential task of Mashiach ben Yossef is to act as precursor to Mashiach ben David: he will prepare the world for the coming of the final redeemer. Different sources attribute to him different functions, some even charging him with tasks traditionally associated with Mashiach ben David (such as the ingathering of the exiles, the rebuilding of the Bet Hamikdash, and so forth).
The principal and final function ascribed to Mashiach ben Yossef is of political and military nature. He shall wage war against the forces of evil that oppress Israel…
The immediate results of this war will be disastrous: Mashiach ben Yossef will be killed. This is described in the prophecy of Zechariah, who says of this tragedy that “
they shall mourn him as one mourns for an only child.” (Zechariah 12:10).
His death will be followed by a period of great calamities. These new tribulations shall be the final test for Israel, and
shortly thereafter Mashiach ben David shall come, avenge his death, resurrect him, and inaugurate the Messianic era of everlasting peace and bliss. – from
Chabad,org <<<