Gog and Magog started as a man and his land, then became end-time hordes
In the Book of Ezekiel, Gog is a ruler and Magog is his country. Over the following centuries the pair merged into a single menacing phrase, were walled off by Alexander the Great in legend, turned up on medieval world maps, and were even pinned on the Vikings. In London, the names ended up on two giant statues.
The names appear in the Hebrew Bible, the New Testament and the Quran. Ezekiel, a priest taken into exile in Babylon, recorded an oracle in which Gog of Magog and his hordes attack a restored Israel and are destroyed, after which God dwells with his people in lasting peace. The meaning of Gog is unknown. Some have tried to match him with Gyges, a seventh-century BC king of Lydia, but many scholars doubt he refers to any historical figure. Genesis names Magog as a grandson of Noah through Japheth, with no Gog at all.
Joining the two into Gog and Magog may have begun as shorthand in the Septuagint, the ancient Greek rendering of Jewish scripture. By the time Revelation was written, the pair stood for the hostile nations of the world, and one strand of Christianity cast them as allies of Satan at the close of the millennium. Jewish tradition saw them instead as enemies whom the Messiah would defeat, opening the Messianic Age.
By Roman times a legend held that Alexander the Great had built gates to keep them out. The historian Josephus identified them with the Scythians, and medieval writers variously proposed the Huns, Khazars, Mongols, Vikings or the Ten Lost Tribes. The Alexander Romances added cannibalism, and medieval world maps sometimes showed them beside Alexander's wall. The Quran calls them Yajuj and Majuj, unruly tribes barred off by a righteous ruler, Dhu'l-Qarnayn, He of the Two Horns, and some Muslim geographers of the Viking age thought the northern raiders were those tribes breaking loose.
The phrase also travelled to Britain. It may lie behind Gogmagog, a legendary British giant, and a garbled later retelling produced two giants called Gog and Magog, the figures with which the statues in London's Guildhall came to be identified.
Source: Gog and Magog