Prophecies can get complicated quickly. In chapter 38, Ezekiel starts looking further down the road and speaks of a coming enemy of God that will threaten Israel. He speaks of "Gog, of the land of Magog" (vs. 2). But just who and where is that?
First, let's answer the question when. It appears that this prophecy has not yet been fulfilled, for it is meant for "the latter years": "After many days you shall be mustered; in the latter years you shall go against a land restored from war, a land where people were gathered from many nations on the mountains of Israel, which had long lain waste; its people were brought out from the nations and now are living in safety, all of them" (vs. 8). It's no wonder that modern end-times scholars often cite this passage as something that could happen in our day and age. We live at a time when Israel has been restored following a great war, and we now have Israelis living in their new nation from many previous lands.
"Magog" appears to be a great, numerous nation and most often associated with "the north". Magog is mentioned in Genesis 10:2 - but as a person, not a country, a descendant of Japheth. However, many times the region where a person landed became known or named for that person (Canaan, Sidon, etc.) Along with Magog in Genesis 10 are mentioned Tubal and Meshech, who appear again with him in Ezekiel 38:2 and 38:3.
"Gog" here indicates a person, "the chief prince." Apparently the ruler of Magog, Gog is thought to be a primary enemy of God's people, perhaps even a stand-in for the antichrist himself.
So just where is Magog? And who is Gog? The short answer is that we don't know. But that hasn't stopped LOTS of speculation. The theory that I hear advanced most often is that Magog is a code word for Russia. It certainly meets the characteristics of a numerous nation from the north, often hostile to Israel. Gog would therefore be the leader or ruler of Russia. But it's important to remember that represents just a best guess, and that the real answer could make itself apparent later.
Gog and Magog show up later in scripture, at the very end of the Bible. Revelation 20:7-8 tells us: "When the thousand years are ended, Satan will be released from his prison and will come out to deceive the nations at the four corners of the earth, Gog and Magog, in order to gather them for battle; they are as numerous as the sands of the sea." Their story ends in the next verse, as their forces attack the "beloved city" (presumed to be Jerusalem, which also lines up with Ezekiel 38) and are consumed by fire from heaven.
Whoever Gog and Magog may be, the Bible is clear that they will end up losing the war to God.