In the Quran, Muhammad taught that Zul-Qarnain - who is Alexander the Great - encountered a group of people oppressed by "Gog and Magog", and aided them as follows:
Surah 18:92-100
92 Then he travelled a ˹third˺ course
93 until he reached ˹a pass˺ between two mountains. He found in front of them a people who could hardly understand ˹his˺ language.
94 They pleaded, "O Ⱬul-Qarnain! Surely Gog and Magog are spreading corruption throughout the land. Should we pay you tribute, provided that you build a wall between us and them?"
95 He responded, "What my Lord has provided for me is far better. But assist me with resources, and I will build a barrier between you and them.
96 Bring me blocks of iron!" Then, when he had filled up ˹the gap˺ between the two mountains, he ordered, "Blow!" When the iron became red hot, he said, "Bring me molten copper to pour over it."
97 And so the enemies could neither scale nor tunnel through it.
98 He declared, "This is a mercy from my Lord. But when the promise of my Lord comes to pass, He will level it to the ground. And my Lord's promise is ever true."
99 On that Day, We will let them surge ˹like waves˺ over one another. Later, the Trumpet will be blown, and We will gather all ˹people˺ together.
100 On that Day We will display Hell clearly for the disbelievers,
Above, notice that Zul-Qarnain built an iron and copper wall between two mountains to block a mountain pass, and this wall was so large that the tribes of Gog and Magog "could neither scale nor tunnel through it". And, judging by verses 98-99, there is a Day in which Allah will allow the barrier to fall, and Gog and Magog will attack.
This incident is also referenced in one other place in the Quran:
Surah 21:95-97
95 It is impossible for a society which We have destroyed to ever rise again,
96 until ˹after˺ Gog and Magog have broken loose ˹from the barrier˺, swarming down from every hill,
97 ushering in the True Promise. Then - behold! - the disbelievers will stare ˹in horror, crying,˺ "Oh, woe to us! We have truly been heedless of this. In fact, we have been wrongdoers."
So, the Quran appears to teach that somewhere on earth, Zul-Qarnain, who is the same person that the Quran describes as having traveled to where the sun rises and sets (Surah 18:83-91), has contained a violent army, which, when loosed by Allah, will cause great suffering.
From the Hadith, it can be demonstrated even more explicitly that Muhammad taught that Gog and Magog breaching their barrier was a sign of the end times:
Sahih Muslim 2901a
Hudhaifa b. Usaid al-Ghifari reported:
Allah's Messenger (ﷺ) came to us all of a sudden as we were (busy in a discussion). He said: What do you discuss about? They (the Companions) said. We are discussing about the Last Hour. Thereupon he said: It will not come until you see ten signs before and (in this connection) he made a mention of the smoke, Dajjal, the beast, the rising of the sun from the west, the descent of Jesus son of Mary (Allah be pleased with him), the Gog and Magog, and land-slides in three places, one in the east, one in the west and one in Arabia at the end of which fire would burn forth from the Yemen, and would drive people to the place of their assembly.
This is also narrated in Sahih Muslim 2901b-d, Sunan Ibn Majah 4055, and Sunan Abi Dawud 4311.
And, in keeping with his theme that the Last Hour was near (Sahih al-Bukhari 5301, etc.), Muhammad taught that the barrier withholding Gog and Magog had been weakened or damaged during the time he was alive, and consequently, the terror they would bring was "nearly approaching":
Sahih al-Bukhari 7059
Narrated Zainab bint Jahsh:
The Prophet (ﷺ) got up from his sleep with a flushed red face and said, "None has the right to be worshipped but Allah. Woe to the Arabs, from the Great evil that is nearly approaching them. Today a gap has been made in the wall of Gog and Magog like this." (Sufyan illustrated by this forming the number 90 or 100 with his fingers.) It was asked, "Shall we be destroyed though there are righteous people among us?" The Prophet (ﷺ) said, "Yes, if evil increased."
This is also narrated in Sahih al-Bukhari 3346-47, 3598, 5293, 7135-36, Sahih Muslim 2880a-d, 2881, 2937a, and Sunan Ibn Majah 3953.
And, according to a narration, the reason that Gog and Magog have not climbed, walked around, dug around, or broken through Zul-Qarnain's wall at some point in the last 1,400 years is because Allah keeps them in a state of confusion, and miraculously repairs the wall that Zul-Qarnain built, every day, until one day he will allow them to breach the wall, and they will attack the whole world, and even the people of the sky:
Sunan Ibn Majah 4080
It was narrated from Abu Hurairah that the Messenger of Allah (ﷺ) said:
"Gog and Magog people dig every day until, when they can almost see the rays of the sun, the one in charge of them says: "Go back and we will dig it tomorrow." Then Allah puts it back, stronger than it was before. (This will continue) until, when their time has come, and Allah wants to send them against the people, they will dig until they can almost see the rays of the sun, then the one who is in charge of them will say: "Go back, and we will dig it tomorrow if Allah wills.' So they will say: "If Allah wills."
Then they will come back to it and it will be as they left it. So they will dig and will come out to the people, and they will drink all the water. The people will fortify themselves against them in their fortresses. They will shoot their arrows towards the sky and they will come back with blood on them, and they will say: "We have defeated the people of earth and dominated the people of heaven." Then Allah will send a worm in the napes of their necks and will kill them thereby.'" The Messenger of Allah (ﷺ) said: "By the One in Whose Hand is my soul, the beasts of the earth will grow fat on their flesh."
This is also narrated in Sahih Muslim 2937b, and Sunan Ibn Majah 4075, 4079, 4081.
And, when they finally arrive, there will be so many of them that they will be able to drink the entire Lake of Tiberias (Sahih Muslim 2937a, Sunan Ibn Majah 4075), and Muslims will use their bows, arrows, and shields as firewood, for 7 years afterward (Sunan Ibn Majah 4076).
There are also narrations which indicate that for every Muslim, there will be 1,000 people from Gog and Magog:
Sahih al-Bukhari 4741
(When the Prophet (ﷺ) mentioned this), the people were so distressed (and afraid) that their faces got changed (in color) whereupon the Prophet (ﷺ) said, "From Gog and Magog nine-hundred ninety-nine will be taken out and one from you. You Muslims (compared to the large number of other people) will be like a black hair on the side of a white ox, or a white hair on the side of a black ox, and I hope that you will be one-fourth of the people of Paradise."
This is also narrated in Sahih al-Bukhari 3348, 6530.
So, what can be made of the Quran and Hadith's accounts of Gog and Magog? Obviously, building a wall of iron big enough to block a mountain pass, which massive tribes of savage warriors cannot scale or dig around, would be prohibitive even today, let alone for Zul-Qarnain. There is a reason dams are built with reinforced concrete, not solid metal.
Also, in modern times, the entire earth can be seen with satellites, and there is no wall, and no vast, savage tribes, waiting to destroy all peoples of the earth, each day barely held back by a miraculous repair to Zul-Qarnain's wall. Therefore, Muhammad's false prophecy and narrative with respect to Gog and Magog is disproven, which refutes the integrity of both the Quran and Hadith.
Informed Muslims, in response, would state that Gog and Magog belong to the realm of the unseen, and that is why no one has found them yet. However, the Quran's account tells of an actual Muslim man, Zul-Qarnain, who, while traveling the world, stops to aid people who ask for protection from Gog and Magog. He then builds a wall of metal between a mountain pass, as covered above. That does not describe the world of the unseen, at all. There is no indication - unless one wants to admit that Zul-Qarnain's story is entirely legendary - that Gog and Magog were not intended to be understood as tribes of people, living on planet earth.
Muhammad's doctrine of Gog and Magog belongs to the category of claims that would have been hard to refute in Muhammad's time, yet can be easily shown to be false in modern times. Muhammad said that there were savage tribes, somewhere on earth, that would be kept at bay by a supernatural wall created by a Muslim man, until an appointed time. This claim was false, demonstrating that Muhammad was a false prophet.