Short answer
Islam teaches that God (﷾) punishes no one until a messenger has reached them. The Qur'an also says every people on earth had a warner sent to them. So no one is condemned for a message that never came. Many Christians, evangelicals especially, read John 14:6 and Acts 4:12 another way. On their reading, no one is saved without faith in Jesus. That leaves no hope for the millions in the Americas, China or Australia who lived and died before a missionary reached them. Nor does it leave any for the peoples of distant lands who lived and died before Jesus came. (The Catholic Church teaches that those who never heard, through no fault of their own, can be saved if they sincerely seek God (﷾).) Islam's answer fits a just and merciful God (﷾). Each person is judged by the message that reached them, and by what they did with it.
Full explanation
No punishment before a messenger
The Qur'an states the rule plainly: God (﷾) does not punish until He has sent a messenger to warn. It gives the reason. Messengers were sent so that no one would have a plea against God (﷾). So no soul is condemned for failing to hear a message that never reached it.
“Who receiveth guidance, receiveth it for his own benefit: who goeth astray doth so to his own loss: No bearer of burdens can bear the burden of another: nor would We visit with Our Wrath until We had sent a messenger (to give warning).”
“Messengers who gave good news as well as warning, that mankind, after (the coming) of the messengers, should have no plea against Allah: For Allah is Exalted in Power, Wise.”
Every people had a messenger
The Qur'an says God (﷾) sent a messenger to every people, and that there was never a people without a warner among them. Some of these messengers are named and many are not. So God (﷾) did not speak only in the Middle East. The Qur'an's words leave no people out, and that takes in the Americas and the Far East. If the message did not reach someone, the rule applies: God (﷾) punishes no one before a messenger comes.
“For We assuredly sent amongst every People a messenger, (with the Command), "Serve Allah, and eschew Evil": of the People were some whom Allah guided, and some on whom error became inevitably (established). So travel through the earth, and see what was the end of those who denied (the Truth).”
“Verily We have sent thee in truth, as a bearer of glad tidings, and as a warner: and there never was a people, without a warner having lived among them (in the past).”
“We did aforetime send messengers before thee: of them there are some whose story We have related to thee, and some whose story We have not related to thee. It was not (possible) for any messenger to bring a sign except by the leave of Allah: but when the Command of Allah issued, the matter was decided in truth and justice, and there perished, there and then those who stood on Falsehoods.”
Judged with justice by what reached them
The Qur'an says that when a people's messenger comes, the matter is judged between them with justice and they are not wronged. On the Day of Judgement not a soul is dealt with unjustly in the least. The Prophet (ﷺ) tied the warning to hearing. He spoke of the Jew or Christian who hears of him and dies rejecting his message.
“To every people (was sent) a messenger: when their messenger comes (before them), the matter will be judged between them with justice, and they will not be wronged.”
“We shall set up scales of justice for the Day of Judgment, so that not a soul will be dealt with unjustly in the least, and if there be (no more than) the weight of a mustard seed, We will bring it (to account): and enough are We to take account.”
Abu Huraira reports that the Prophet (ﷺ) swore that any Jew or Christian of his community who hears of him, then dies without believing in the message he was sent with, will be among the people of the Fire.
The verses behind "no other way"
Many Christians, especially evangelicals, read these verses strictly. Jesus is the only way to the Father, and there is no other name by which people must be saved. Paul, a Christian missionary of the first century, asks how people can believe in one they have not heard of. This drives Christian missions.
“Jesus saith unto him, I am the way, the truth, and the life: no man cometh unto the Father, but by me.”
“Neither is there salvation in any other: for there is none other name under heaven given among men, whereby we must be saved.”
“How then shall they call on him in whom they have not believed? and how shall they believe in him of whom they have not heard? and how shall they hear without a preacher?”
What the churches have taught
In 1442 the Council of Florence (a gathering of Catholic bishops) declared that no one outside the Catholic Church could share in eternal life. It named pagans (people who worship other gods) as well. In 1863 Pope Pius IX taught that some people are ignorant of the faith through no fault of their own. If they keep the natural law (the moral sense God (﷾) puts in every heart), they can attain eternal life. In 1964 the Second Vatican Council said those who sincerely seek God (﷾) can be saved. Many evangelical Protestants hold the stricter view. The churches' official wording has moved over the centuries. The Qur'an gave its answer in the seventh century, and it has not changed.
The bull of union with the Copts declares that the Church firmly believes that no one outside the Catholic Church, not only pagans but also Jews, heretics and schismatics, can share in eternal life, and that they will go into the everlasting fire unless they are joined to the Church before the end of their lives.
The encyclical teaches that those who are invincibly ignorant of the Catholic religion, and who keep the natural law, are ready to obey God and live an upright life, can attain eternal life by the power of divine light and grace.
Teaches that those who, through no fault of their own, do not know the Gospel of Christ or his Church, but sincerely seek God and, moved by grace, try to do His will as their conscience shows it, can attain salvation.
Verse by verse
Acts 4:12 — Acts of the Apostles, chapter 4, verse 12
“Neither is there salvation in any other: for there is none other name under heaven given among men, whereby we must be saved.”
Cited for
All have sinned and are justly condemned for their own sin. Salvation is only by faith in Jesus, so those who never heard have no way to be saved.
The response
Romans 1:20 says they are without excuse. On this reading, though, it gives them no way to be saved, because the only cure, faith in Jesus, never reached them. The Qur'an holds each soul to the message that reached it, and punishes no one before a messenger comes.
Where it lands — On that reading, the cure was out of reach for millions through no choice of their own. The Qur'an's rule leaves no one without a warner.
John 14:6 — Gospel of John, chapter 14, verse 6
“Jesus saith unto him, I am the way, the truth, and the life: no man cometh unto the Father, but by me.”
Cited for
No one comes to the Father except through Jesus, so there is no salvation apart from faith in him.
The response
John 14:6 names the way to the Father. It does not say what God (﷾) does with those the way never reached. The Qur'an does: each people is judged by the messenger sent to it.
Where it lands — The verse does not answer the case of those who never heard; the Qur'an does.
Perspectives
Evangelical Christian
Salvation comes only through conscious faith in Jesus Christ. That is why the Gospel must be preached to every nation.
Jesus says no one comes to the Father except through him.
Rebuttal
John 14:6 names the way to the Father but does not say what God (﷾) does with those the way never reached. The Catholic Church reads it as leaving them hope. The Qur'an says God (﷾) punishes no one before a messenger comes.
Peter says there is salvation in no other name.
Rebuttal
Acts 4:12 says there is salvation in no other name. It does not say whom God (﷾) judges for never hearing that name. The Qur'an says God (﷾) sent a warner to every people and punishes no one before a messenger comes.
Paul says people cannot believe in one they have not heard of, and cannot hear without a preacher.
Rebuttal
Islam agrees that people cannot believe in a message that has not reached them. That is why the Qur'an says God (﷾) sent a messenger to every people, and punishes no one before one comes.
Paul says that creation makes God known, so people are without excuse.
Rebuttal
Islam agrees that creation points to God (3:190-191). But the Qur'an says God (﷾) punishes no one until a messenger comes (17:15). On the strict reading, Romans 1:20 leaves people without excuse yet with no way to be saved.
Catholic
The Catholic Church teaches that some people do not know the Gospel through no fault of their own. If they sincerely seek God, they can be saved.
Lumen Gentium 16 (a teaching of the Second Vatican Council) speaks of people who do not know the Gospel through no fault of their own. If they sincerely seek God, they can attain salvation.
Rebuttal
Islam agrees that a person who never heard is not condemned for it. Islam goes further. It says God (﷾) sent a warner to every people, and judges each by the message that reached them.
The Islamic perspective
God (﷾) punishes no one until a messenger has reached them, and He sent a messenger to every people. Each person is judged by the message that reached them. No one is condemned because of when or where they were born.
The Qur'an teaches that God (﷾) does not punish until He has sent a messenger.
The Qur'an teaches that every people had a messenger or warner, many of them not named.
If salvation comes only by faith in Jesus, the way to be saved was kept from millions by when and where they were born. It was no choice of their own.
Florence in 1442 declared that no one outside the Church, pagans included, could share in eternal life. In 1863 Pope Pius IX taught that some people are ignorant of the Catholic faith through no fault of their own. If they keep the natural law, they can attain eternal life. In 1964 the Second Vatican Council taught that those who sincerely seek God (﷾) can attain salvation.
The Prophet (ﷺ) tied the warning to hearing. A Jew or Christian who hears of him and dies without believing in his message, he said, will be among the people of the Fire.