Short answer
Prayer in Islam is not a guarantee of riches or top marks. It is worship, owed to the One who made us. Worldly gifts go to everyone. The Qur'an says: "Of the bounties of thy Lord We bestow freely on all" (17:20). So a classmate who never prays can do very well, and Islam expects that. The Prophet (ﷺ) himself slept on a palm-leaf mat while the emperors of Rome and Persia lived in luxury. Islam measures success another way. The one saved from the Fire and admitted to the Garden "will have attained the object (of Life)" (3:185). Islam never said dua replaces effort either: a person "can have nothing but what he strives for" (53:39). And the case for Islam does not rest on answered prayers. It rests on the Qur'an and the Prophet (ﷺ). Prayer still does what it promises. It keeps a person from wrong (29:45), and in remembering God (﷾) hearts find rest (13:28).
Full explanation
What prayer is for
Islam has two kinds of prayer. Salah is the five daily prayers, and dua is asking God (﷾) for something. Salah has requests in it, but it is first of all worship, owed to the One who gave us everything. The Qur'an says God (﷾) created jinn and people "that they may serve Me" (51:56). He does not need it; we do. The Prophet (ﷺ) compared the five prayers to a river at a person's door. If he bathed in it five times a day, no dirt would be left on him. In the same way the five prayers wipe away wrongs. The Qur'an says prayer "restrains from shameful and unjust deeds" (29:45).
“I have only created Jinns and men, that they may serve Me.”
Abu Hurayra heard the Prophet (ﷺ) ask whether any dirt would be left on someone who bathed five times a day in a river at his door. They said not a trace would be left. He said that is the example of the five prayers, by which Allah wipes out evil deeds. Also in Sahih Muslim 667.
“Recite what is sent of the Book by inspiration to thee, and establish regular Prayer: for Prayer restrains from shameful and unjust deeds; and remembrance of Allah is the greatest (thing in life) without doubt. And Allah knows the (deeds) that ye do.”
Worldly gifts go to everyone
Islam never promised that those who pray will be the richest or the cleverest. The Qur'an does say that God (﷾) provides for those who fear Him "from (sources) he never could imagine" (65:3). But that provision is not a race against others, and it is not always money. The Qur'an speaks of those who want this world and those who want the next. Then it says: "Of the bounties of thy Lord We bestow freely on all- These as well as those" (17:20). So a Hindu classmate who never prays and gets top marks proves nothing against prayer. Her mind and her health are gifts from God (﷾) too, whether she thanks Him or not.
“Of the bounties of thy Lord We bestow freely on all- These as well as those: The bounties of thy Lord are not closed (to anyone).”
“And He provides for him from (sources) he never could imagine. And if any one puts his trust in Allah, sufficient is (Allah) for him. For Allah will surely accomplish his purpose: verily, for all things has Allah appointed a due proportion.”
The Prophet (ﷺ) on a palm-leaf mat
Umar, one of the Prophet's (ﷺ) closest Companions, once found him lying on a mat of palm leaves. The mat had left marks on his side, and Umar wept. He said the emperors of Rome and Persia, Caesar and Khosrau, lived in luxury, while God's (﷾) Messenger lived in want. The Prophet (ﷺ) asked him: was he not content that they should have this world, and the believers the next? So the comparison is old. Muslims made it themselves, and the Prophet (ﷺ) answered it.
Umar found the Prophet (ﷺ) lying on a mat of palm leaves with nothing between him and it, a leather pillow stuffed with palm fibre under his head. Seeing the marks of the mat on his side, Umar wept, saying that Caesar and Khosrau lived in luxury while he lived in want. The Prophet asked whether he was not content that they should have this world and the believers the Hereafter.
What counts as success
The Qur'an names the real success: "Only he who is saved far from the Fire and admitted to the Garden will have attained the object (of Life): For the life of this world is but goods and chattels of deception" (3:185). One chapter opens: "The believers must (eventually) win through,- Those who humble themselves in their prayers" (23:1-2). Money, marks and fame end at death. Prayer looks to what comes after it.
“Every soul shall have a taste of death: And only on the Day of Judgment shall you be paid your full recompense. Only he who is saved far from the Fire and admitted to the Garden will have attained the object (of Life): For the life of this world is but goods and chattels of deception.”
“The believers must (eventually) win through,- Those who humble themselves in their prayers;”
Dua and effort go together
Islam does not teach that dua replaces work. The Qur'an says "man can have nothing but what he strives for" (53:39). The Prophet (ﷺ) told the sick to seek treatment, because God (﷾) made a cure for every disease except old age. So a Muslim studies for the exam and also asks God (﷾) for help. If he passes, his effort counted. He thanks God (﷾) as well, because the mind, the time and the health to study came from Him.
“Namely, that no bearer of burdens can bear the burden of another; That man can have nothing but what he strives for;”
Usama ibn Sharik reports that desert Arabs asked the Prophet (ﷺ) whether they should seek medical treatment. He told them to seek treatment, for God has not made any disease without making a remedy for it, except one: old age.
How Islam says dua is answered
God (﷾) says: "Call on Me; I will answer your (Prayer)" (40:60). The Prophet (ﷺ) explained what that answer can be. A Muslim's dua, if it asks for nothing sinful, brings one of three things. It is given soon, or it is stored up for him in the next life, or an equal harm is turned away from him. He also said a dua is answered as long as the person is not impatient. The impatient one says: I prayed, and I was not answered. And the Qur'an says a person may dislike what is good for him and love what is bad for him: "But Allah knoweth, and ye know not" (2:216). Like a child pulled back from a fire, we feel what we were refused, not the harm we were spared.
“And your Lord says: "Call on Me; I will answer your (Prayer): but those who are too arrogant to serve Me will surely find themselves in Hell - in humiliation!"”
Abu Sa'id al-Khudri reports that the Prophet (ﷺ) said no Muslim makes a supplication that asks for nothing sinful and does not cut the ties of kinship without being given one of three things: his supplication is answered soon, or it is stored up for him in the Hereafter, or an equal harm is turned away from him. They said they would then pray much more, and he said Allah has more still to give.
Abu Huraira reports the Prophet (ﷺ) saying that the prayer of any of you is answered as long as he is not impatient, saying: I prayed, and I was not answered.
“Fighting is prescribed for you, and ye dislike it. But it is possible that ye dislike a thing which is good for you, and that ye love a thing which is bad for you. But Allah knoweth, and ye know not.”
What if every dua were granted as asked?
Think what would happen if every dua were granted just as it was asked. Two teams pray to win the same match. Two people pray for the same job. A farmer prays for rain while a traveller prays for a dry road. They cannot all be given what they asked, and the world would fall into chaos. The Qur'an states the principle: "If the Truth had been in accord with their desires, truly the heavens and the earth, and all beings therein would have been in confusion and corruption!" (23:71). The commentator Ibn Kathir explains why: such desires are corrupt and contradict each other. The Qur'an also says that if Allah (﷾) enlarged His servants' provision, "they would indeed transgress beyond all bounds through the earth; but he sends (it) down in due measure as He pleases" (42:27). There is a second problem. If every wish came true the moment it was asked, no one would need to study, work or help anyone. People would do nothing but ask. Yet this life is a test of who is best in deed (67:2). So Islam teaches dua together with effort, never dua in place of it.
“If the Truth had been in accord with their desires, truly the heavens and the earth, and all beings therein would have been in confusion and corruption! Nay, We have sent them their admonition, but they turn away from their admonition.”
Ibn Kathir, citing Mujahid, Abu Salih and al-Suddi, says that the Truth (al-Haqq) here is Allah. He explains that if Allah had responded to the desires in their hearts and prescribed things accordingly, the heavens and the earth and all in them would have been corrupted, because of their corrupt and inconsistent desires.
“If Allah were to enlarge the provision for His Servants, they would indeed transgress beyond all bounds through the earth; but he sends (it) down in due measure as He pleases. For He is with His Servants Well-acquainted, Watchful.”
“He Who created Death and Life, that He may try which of you is best in deed: and He is the Exalted in Might, Oft-Forgiving;-”
Isn't that "heads I win, tails you lose"?
Critics say this answer can never lose. If the dua is granted, God (﷾) gave it. If not, God (﷾) had other plans. That would be a fair point if the case for Islam rested on answered prayers. It rests on other things. There is the Qur'an's challenge, which no one has met (2:23). There are prophecies that came true (30:2-4). And there is the life of the Prophet (ﷺ). A person who believes for those reasons then trusts God (﷾) with his dua. That is trust, not an argument. In the same way, a Muslim may feel that a prayer was answered. That feeling is not proof for anyone else, and Islam does not ask it to be.
“And if ye are in doubt as to what We have revealed from time to time to Our servant, then produce a Sura like thereunto; and call your witnesses or helpers (If there are any) besides Allah, if your (doubts) are true.”
“The Roman Empire has been defeated- In a land close by; but they, (even) after (this) defeat of theirs, will soon be victorious- Within a few years. With Allah is the Decision, in the past and in the Future: on that Day shall the Believers rejoice-”
Abu Sa'id al-Khudri reports that the Prophet (ﷺ) said no Muslim makes a supplication that asks for nothing sinful and does not cut the ties of kinship without being given one of three things: his supplication is answered soon, or it is stored up for him in the Hereafter, or an equal harm is turned away from him. They said they would then pray much more, and he said Allah has more still to give.
Are Muslims less successful?
Wealth and science have moved between peoples all through history. For centuries, many of the world's leading scientists worked in Muslim lands. Today others lead. The reasons historians give are peace, government, resources and history. Some say the Muslim scholars of that age were really Persians, whose work Islam took over. Many were Persians, and they were Muslims. Ibn Sina was born near Bukhara and wrote mostly in Arabic. Others were not Persian at all: al-Kindi was an Arab of the Kinda tribe, born in Kufa. They worked in Muslim cities such as Baghdad and Cairo, centuries after Islam began. And they named what they learned from others. Al-Khwarizmi wrote on the Hindu way of counting, and Ibn al-Haytham wrote Doubts concerning Ptolemy. Islam never said that one people is better than another (49:13).
A history of science in the medieval Muslim world. It covers al-Khwarizmi's algebra, Ibn al-Haytham's optics and Ibn Sina's medicine, and how their work reached Europe in Latin translation.
Ibn Sina (Avicenna, c. 970-1037) was born in Afshana, a village near Bukhara; his father came from Balkh. He wrote in a supple Arabic prose, and wrote one work, the Philosophy for Ala al-Dawla, in Persian.
Al-Kindi was born about 801 in Kufa, Iraq, and died in 873 in Baghdad. He was descended from the royal Kinda tribe, which had come from southern Arabia. The Caliph al-Ma'mun appointed him to the House of Wisdom in Baghdad, where he worked on translating Greek scientific manuscripts.
Al-Khwarizmi lived from about 780 to about 850 and was a scholar at the House of Wisdom in Baghdad under the Caliph al-Ma'mun. His book on arithmetic survives only in a Latin version, known as "Al-Khwarizmi on the Hindu Art of Reckoning", which sets out the Hindu place-value system of numbers. The pious preface to his Algebra shows that he was an orthodox Muslim.
Ibn al-Haytham's critique of Ptolemy, the most respected astronomer of the ancient world. He lists contradictions and weak points in Ptolemy's works, and holds that even the greatest authority must be tested.
“O mankind! We created you from a single (pair) of a male and a female, and made you into nations and tribes, that ye may know each other (not that ye may despise (each other). Verily the most honoured of you in the sight of Allah is (he who is) the most righteous of you. And Allah has full knowledge and is well acquainted (with all things).”
What prayer gives
Five times a day, a Muslim stops, stands before his Lord and speaks to Him, with no go-between. God (﷾) says: "I am indeed close (to them): I listen to the prayer of every suppliant when he calleth on Me" (2:186). The Qur'an says: "without doubt in the remembrance of Allah do hearts find satisfaction" (13:28). The Prophet (ﷺ) said that everything that happens to a believer is good for him. In ease he gives thanks, and in hardship he is patient.
“When My servants ask thee concerning Me, I am indeed close (to them): I listen to the prayer of every suppliant when he calleth on Me: Let them also, with a will, Listen to My call, and believe in Me: That they may walk in the right way.”
“"Those who believe, and whose hearts find satisfaction in the remembrance of Allah: for without doubt in the remembrance of Allah do hearts find satisfaction.”
Suhayb reports that the Prophet (ﷺ) said the affair of the believer is wonderful, for there is good for him in all of it, and this is so for no one but the believer: if something pleasing happens he gives thanks, and that is good for him; if hardship strikes he is patient, and that is good for him.
Perspectives
Prayer does nothing
Many sceptics say prayer does nothing. People who never pray do just as well. Answered prayers, they say, are wishful thinking. And believers explain away every prayer that fails.
People who never pray, such as a Hindu classmate who gets everything right, do as well as or better than those who pray. So prayer is unnecessary.
Rebuttal
Islam never said those who pray would be the cleverest or the richest. The Qur'an says God's (﷾) gifts in this world go to all, "These as well as those" (17:20). Prayer is worship, and it looks to the next life (3:185).
People who feel their prayers were answered are seeing what they want to see.
Rebuttal
A feeling is not proof for anyone else, and Islam does not ask it to be. The case for Islam rests on the Qur'an's challenge, which no one has met (2:23). It also rests on prophecies that came true (30:2-4), not on answered prayers.
Muslims today are less successful than Christians and Jews. If prayer worked, those who pray would be the most successful.
Rebuttal
Wealth has moved between peoples all through history, for reasons of peace, government, resources and history. The Prophet (ﷺ) himself lived on a palm-leaf mat while the emperors of Rome and Persia lived in luxury. He asked Umar whether he was not content that they should have this world, and the believers the next.
The Muslim golden age was really the work of Persians, taken over after Persia was conquered.
Rebuttal
Many of those scholars were Persians, and they were Muslims, writing mostly in Arabic. Others were Arabs, like al-Kindi. They worked centuries after Islam began, and they openly named what they learned from Greeks and Indians.
Muslims win either way. A granted dua is put down to God, and a failed one to God's other plans. That can never be tested.
Rebuttal
It is not offered as a test. The Prophet (ﷺ) taught that a dua is given soon, stored up for the next life, or turns away an equal harm. That is what a believer trusts, not what proves the faith. And Islam does credit effort: a person has only what he strives for (53:39).
The Islamic perspective
Prayer is first of all worship owed to God (﷾). Worldly success He gives to everyone, those who pray and those who do not. A Muslim's sincere dua is answered in one of three ways, and effort is part of faith.
The Qur'an says God (﷾) gives the good things of this world to all. Those who want this world get them, and so do those who want the next.
The Qur'an says real success is to be saved from the Fire and admitted to the Garden.
The Prophet (ﷺ) lived on a palm-leaf mat. He told Umar that the emperors have this world, and the believers the next.
The Prophet (ﷺ) said a dua is given soon, stored for the next life, or turns away an equal harm.
The Qur'an says that if the truth followed people's desires, the heavens and the earth would fall into confusion (23:71). So not every dua can be granted as it was asked.
The Qur'an says a person has only what he strives for, so dua goes with effort.
The Qur'an says prayer keeps a person from shameful and unjust deeds. It says hearts find rest in remembering God (﷾).