What is Moshiach ben Yosef?
Answer: Jewish tradition speaks of two redeemers, each one called Moshiach. Both are involved in ushering in the Messianic era. They are Moshiach ben David and Moshiach ben Yossef.
The term Moshiach unqualified always refers to Moshiach ben David (Moshiach 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.
Moshiach ben Yossef (Moshiach the descendant of Joseph) of the tribe of Ephraim (son of Joseph), is also referred to as Moshiach ben Ephrayim, Moshiach the descendant of Ephraim. He will come first, before the final redeemer, and later will serve as his viceroy.
The essential task of Moshiach ben Yossef is to act as precursor to Moshiach 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 Moshiach ben David (such as the ingathering of the exiles, the rebuilding of the Bet Hamikdash, and so forth).