The prophet Ezekiel (chapters 38-39) describes a climactic battle that will be instigated by Gog and/of Magog, and will be waged against Israel and G‑d. The defeat of Gog and Magog will precipitate the Messianic Redemption. It is difficult to dwell on this topic because it is so shrouded in mystery. We are uncertain as to the identity of Gog and Magog, whether Gog and Magog are the names of nations or individuals, whether this battle will be a physical or spiritual battle, and even whether it has already occurred or not.

Some say that Elijah will arrive before the war of Gog and Magog, while others say that he will arrive three days prior to the revelation of Moshiach.

According to tradition, the central personality in this war is Moshiach ben YosefAccording to tradition, the central personality in this war is Moshiach ben Yosef—Moshiach of the tribe of Joseph. 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 Yosef. (The unqualified term "Moshiach," however, belongs exclusively to Moshiach ben David, the ultimate redeemer.)

Moshiach ben Yosef will be killed in the war against Gog and Magog. Again, it is unclear whether the death will be in physical battle, or as a result of the spiritual battles which he will wage against the forces of evil. Either way, the prophet Zechariah (12:10) describes the national mourning that will follow his death.

Apparently, though, the death of Moshiach ben Yosef is not inevitable. The master-kabbalist Rabbi Isaac Luria, known as the Arizal, said that when saying in the Amidah the words, "speedily establish the throne of Your servant David," one should beseech G‑d that Moshiach ben Yosef should not die in the course of his struggles.

According to certain sources, Moshiach be Yosef will serve as Moshiach ben David's viceroy. Thus finally bringing to an end the schism between the northern Ten Tribes, which were ruled by Joseph's descendants, and the Kingdom of Judea, which was ruled by the Davidic dynasty.

Click here for a more comprehensive discussion regarding Moshiach ben Yosef.