The tradition of Gog and Magog begins in the Hebrew Bible with the reference to Magog, son of Japheth, in the Book of Genesis and continues in cryptic prophecies in the War of Ezekiel 38-39, which are echoed in the Book of Revelation and in the Qur'an. The tradition is very ambiguous with even the very nature of the entities differing between sources. They are variously presented as men, supernatural beings (giants or demons), national groups, or lands. Gog and Magog occur widely in mythology and folklore.
Gog and Magog in religious works
Hebrew Bible
painting from the 16th century illustrating the building of the wall]]The first occurrence of "Magog" in the Hebrew Bible is in the Table of Nations in Genesis 10, where Magog is the eponymous ancestor of a people or nation (without any accompanying apocalyptic symbolism, or mention of Gog, although "Magog" may mean "the land of Gog"):
2. The sons of Japheth were Gomer, Magog, Madai, Javan, Tubal, Meshech, and Tiras
3. The sons of G
Source:
http://en.wikipedia.org/wiki/Magog