General Context
This verse follows the final condition Moses set: ﴿إِن سَأَلۡتُكَ عَن شَيۡءِۭ بَعۡدَهَا فَلَا تُصَٰحِبۡنِي﴾ (“If I should ask you about anything after this, then do not keep me as a companion”, Qur’an 18:76). The story seems to have reached its last threshold. The companionship has one test left. Moses can bear it patiently to the end or the two will part. Now comes the third scene. It takes place in a town, away from the sea where the ship was pierced and the road where the boy was met and killed. Among these inhospitable people the prophet and the righteous servant grow hungry. They ask for food and are refused hospitality. Al-Khidr then finds a wall about to fall and sets it upright without taking payment.
On the surface the scene is less terrible than the killing of the boy, yet it puts the soul to a subtler test. There is no bloodshed to arouse Moses and no ship whose passengers might drown. There is hunger, deprivation, and a poor reception from the townspeople. A different question arises. Why should al-Khidr do a good turn for people who refused them hospitality? Why give his labor freely when the two of them need food? This time Moses speaks by way of a gentle suggestion rather than an outright objection: ﴿لَوْ شِئْتَ لَاتَّخَذْتَ عَلَيْهِ أَجْرًا﴾ (“If you wished, you could have taken for it a payment.”, Qur’an 18:77). It is still a question after the condition, and it brings the companionship to an end.
Explaining the verse, al-Tabari writes: “Allah, exalted be His mention, says that Moses and the man of knowledge went on ﴿حَتّى إذَا أتَيَا أهْلَ قَرْيَةٍ اسْتَطْعمَا أهْلَها﴾ (“until when they came to the people of a town, they asked its people for food”, Qur’an 18:77), asking them for food. They gave them none. The two asked for hospitality ﴿فَأبَوْا أن يُضَيّفُوهُما فَوَجَدَا فِيها جِدَارا يُرِيدُ أنْ يَنْقَضّ﴾ (“but they refused to offer them hospitality. And they found therein a wall about to collapse”, Qur’an 18:77). They found a wall in the town about to collapse and fall. The same expression is used of a house that has fallen into ruin.” — Jamiʿ al-Bayan ʿan Taʾwil Ay al-Qur’an — Muhammad ibn Jarir al-Tabari.
The test of patience now moves from apparent wrongdoing to a kindness that seems misplaced. On the ship Moses in effect asks, “How could you damage the ship of people who were kind to us?” In the town the question is, “How can you be kind to people who treated us badly?” The knowledge al-Khidr acts on is guided by the outcome Allah will disclose shortly, beyond the immediate exchange of good or ill treatment. The wall belonged to two orphan boys, with a treasure of theirs buried beneath it. Their father had been righteous.
Rhetorical Outpourings
The words ﴿فَٱنطَلَقَا﴾ (“So they set out”, Qur’an 18:77) set the companions going for a third time. This return to the journey is deliberate. Each departure opens another stage of the teaching, first the ship, then the boy, then the town. Each changes the nature of the test. The first involves fear of possible harm. The second brings harm that appears to have been done. The third concerns a possible benefit foregone, or a good deed done without return for those who seem undeserving.
The verse says ﴿أَهۡلَ قَرۡيَةٍ﴾ (“to the people of a town”, Qur’an 18:77) and then ﴿ٱسۡتَطۡعَمَآ أَهۡلَهَا﴾ (“they asked its people for food”, Qur’an 18:77). It names the people twice rather than saying “they asked them for food.” Making the noun explicit draws attention to those who refused hospitality among the inhabitants, without passing judgment on each person living there. The two come to people of a town, ask its people for food, and those people refuse to receive them. The wording builds up the sense of meanness in how they respond.
On this point, Ibn ʿAshur writes: “The words ﴿أَهْلَهَا﴾ (“its people”, Qur’an 18:77) are made explicit instead of a pronoun, as in ‘they asked them for food.’ This makes the expression more direct in censuring their meanness, for they refused to show the two hospitality. Hospitality had been widely practiced among peoples since the time of Abraham, peace be upon him. It was an established way for people to support one another.” — Al-Tahrir wa-l-Tanwir — Muhammad al-Tahir Ibn ʿAshur.
Another subtle point is that Allah first says ﴿قَرۡيَةٍ﴾ (“a town”, Qur’an 18:77) and then in the explanation says ﴿وَأَمَّا ٱلۡجِدَارُ فَكَانَ لِغُلَٰمَيۡنِ يَتِيمَيۡنِ فِي ٱلۡمَدِينَةِ﴾ (“And as for the wall, it belonged to two orphan boys in the city”, Qur’an 18:82). Al-Maturidi notes this: “﴿فانْطَلَقا حتّى إذا أَتَيَا أهْلَ قريةٍ﴾ (“So they set out, until when they came to the people of a town”, Qur’an 18:77) calls it a qaryah, yet it was a city. Do you not see that He says at the end ﴿وأمّا الجِدارُ فكان لِغُلامَيْنِ يَتِيمَيْنِ في المدينةِ﴾ (“And as for the wall, it belonged to two orphan boys in the city”, Qur’an 18:82)? This shows it was a city. The Arabs may call a city a qaryah.” — Taʾwilat Ahl al-Sunnah — Muhammad ibn Muhammad al-Maturidi.
The difference of expression has a subtle effect on the meaning. In the account of meanness it is called “a town” and when the orphans’ right is protected it is called “the city.” The terms can apply to the same place in Arabic. The change suits what is at issue in each scene, the people who refused hospitality, then two orphans protected there by Allah’s care.
The words ﴿جِدَارٗا يُرِيدُ أَن يَنقَضَّ﴾ (“a wall about to collapse”, Qur’an 18:77) are a remarkable instance of personification in the Qur’an. The wall is given a will like that of a living being. It was so close to collapsing that it seemed to want to fall, without having a real will like a human being.
Explaining this usage, al-Tabari writes: “The same is true of His words ﴿جِدَارا يُرِيدُ أنْ يَنْقضّ﴾ (“a wall about to collapse”, Qur’an 18:77). You already know that their meaning is that it was close to falling or collapsing. Allah, glorious be His praise, addressed through the Qur’an the people in whose language the revelation was sent down, and they understood what He meant.” — Jamiʿ al-Bayan ʿan Taʾwil Ay al-Qur’an — Muhammad ibn Jarir al-Tabari.
On the same rhetorical point, Ibn ʿAshur writes: “﴿يُرِيدُ أن يَنقَضَّ﴾ (“about to collapse”, Qur’an 18:77) means that the wall leaned and was on the verge of collapse, that is, it was about to fall. Its nearness to collapse is expressed as a desire to collapse, in an explicit metaphor carried by the verb. Its imminent fall is likened to the intention of a thinking being who is about to do something because he has decided to do it.” — Al-Tahrir wa-l-Tanwir — Muhammad al-Tahir Ibn ʿAshur.
The metaphor makes the wall a presence in the scene, leaning and weary, as though it wanted to fall. It is as though the Qur’an were drawing our attention to how something about to fall may conceal a treasure, and how an apparently ordinary wall in danger of collapse may be the shelter Allah has given to the provision of two orphans.
Interpretive and Reflective Outpourings
One of the great insights of this verse is that Allah may protect someone vulnerable without their knowing it, through hands they do not know, at a time when they cannot protect their own rights. The two orphan boys are absent from the scene. They do not ask for food or for the wall to be repaired. The text does not show them taking part in the request for its repair or knowing what is being done to it. Yet Allah brings Moses and al-Khidr to the town and makes hunger, meanness, and deprivation part of the way the orphans’ treasure is kept safe.
The full insight only emerges in the explanation that follows: ﴿وَأَمَّا ٱلۡجِدَارُ فَكَانَ لِغُلَٰمَيۡنِ يَتِيمَيۡنِ فِي ٱلۡمَدِينَةِ وَكَانَ تَحۡتَهُۥ كَنزٞ لَّهُمَا وَكَانَ أَبُوهُمَا صَٰلِحٗا﴾ (“And as for the wall, it belonged to two orphan boys in the city, and there was beneath it a treasure for them, and their father had been righteous”, Qur’an 18:82). The kindness was for the two orphans who do not appear in the scene. The inhospitable townspeople were not its beneficiaries. Moses sees the people of the town. Al-Khidr sees the wall, what it covers, and the people for whom it matters. One sees the meanness before him. The other acts to protect a right that cannot yet be seen.
Al-Biqaʿi connects the expression with the people’s conduct: “He then gives an account of the town, to show that it has a part in its people’s meanness, with His words ﴿استطعما﴾ (Qur’an 18:77). He names the people explicitly in ﴿أهلها﴾ (“its people”, Qur’an 18:77) instead of using a pronoun because they asked for food from some of those they had met. It is also possible that they came to some people and asked others for food, the two groups being different. This is the more apparent sense because it accords with common practice. […] ﴿فأبوا﴾ (“but they refused”, Qur’an 18:77) means that those among the townspeople whom they asked for food consequently refused ﴿أن يضيفوهما﴾ (“to offer them hospitality”, Qur’an 18:77), that is, to give them lodging and food, and so the two turned away from them.” — Nazm al-Durar fi Tanasub al-Ayat wa-l-Suwar — Ibrahim ibn ʿUmar al-Biqaʿi.
On the wall, he continues: “﴿فوجدا فيها﴾ (“And they found therein”, Qur’an 18:77) means in the town. He did not say ‘among them,’ indicating that the intent is to depict the town’s ill nature. ﴿جداراً﴾ (“a wall”, Qur’an 18:77), a wall on the verge of falling. He also lends what cannot think a quality of what can think, saying ﴿يريد أن ينقض﴾ (“about to collapse”, Qur’an 18:77), meaning to collapse quickly. Al-Khidr passed his hand over it ﴿فأقامه﴾ (“so al-Khidh r restored it”, Qur’an 18:77).” — Nazm al-Durar fi Tanasub al-Ayat wa-l-Suwar — Ibrahim ibn ʿUmar al-Biqaʿi.
A second insight follows. Do not let people’s bad conduct keep you from safeguarding the rights of the innocent among them. The townspeople refused hospitality, yet there were two orphans there protected on account of their father’s righteousness. If al-Khidr had given the town only what it appeared to deserve, he would have left the wall to fall and the orphans would have lost their right. This is one of the great lessons of the story. Living among a mean people does not make someone deserving of harsh treatment. Among them there may be an orphan, a vulnerable person, a righteous person out of sight, or the trace of an earlier righteousness through which Allah protects descendants.
A third insight is that a parent’s righteousness can help protect their children. The explanation does not say that the boys themselves were righteous. It says ﴿وَكَانَ أَبُوهُمَا صَٰلِحٗا﴾ (“and their father had been righteous”, Qur’an 18:82). The father’s righteousness became a means by which the treasure was preserved after his death and the boys were protected until they reached maturity. There is great good news in this for fathers and mothers. The effects of piety can extend beyond their lifetimes and still be at work in their children’s lives.
A fourth insight is that Allah may delay a provision out of mercy to the one who will receive it. The treasure is there, under the wall, and the wall will stand until the boys reach maturity. If it had come to light too soon, it might have been lost, someone in the town might have laid claim to it, or the orphans might have been unable to safeguard it. Concealed provision need not be deprivation, and delay need not be withholding. Sometimes the wall that hides the treasure is itself the mercy that keeps it safe.
Spiritual Outpourings
Two scenes stand side by side: doors people keep shut and the shelter Allah opens. The two ask the townspeople for food and are refused. Then al-Khidr restores a wall that conceals the treasure of two orphan boys. It is as though the verse says, “Someone may deny you a bite to eat while Allah, at that very moment, is safeguarding a treasure you do not see.” Do not let the meanness of people hide from you the gentleness of the Truth.
Sayyid Qutb depicts the scene: “They are hungry, in a town whose people are miserly, feeding no hungry person and taking in no guest. Then he finds a leaning wall on the point of collapse. The expression lends the wall the life and will of the living: ﴿يريد أن ينقض﴾ (“about to collapse”, Qur’an 18:77). And there is the stranger, setting about putting the wall straight for nothing in return!” — In the Shade of the Qur’an — Sayyid Qutb Ibrahim Husayn al-Shadhili.
This picture puts us inside Moses’ experience. He is hungry, has been turned away, and now sees his teacher give his own labor freely among the very people who did so. Al-Khidr is acting for Allah, for the orphans, on account of their father’s righteousness, and with a view to an outcome still out of sight. There is a profound spiritual lesson in this. Do not make kindness depend entirely on the worthiness of the person in front of you. It may appear to benefit them when its true benefit lies with someone else, or when the act is for Allah alone.
One subtlety is that the wall “wants” to collapse, yet Allah wills that it stay up. Outwardly there is an impulse toward collapse, while in the unseen there is a will to preserve. We often encounter something like this. A home, a heart, a livelihood, a child, or a future appears about to give way. Allah sends someone to set it right through a kindness no one thought of. When Allah protects someone, He may set a leaning wall upright for them even in an inhospitable town.
On the deeper meaning of this journey, al-Qushayri writes: “It is said that this was a journey of discipline, and Moses was therefore returned to the task of bearing hardship. When he drew water for Shuʿayb’s daughters, he had suffered greater fatigue and hunger. At that time he himself was being carried, whereas now he was the one doing the bearing.” — Lataʾif al-Isharat — ʿAbd al-Karim ibn Hawazin al-Qushayri.
Al-Qushayri gives this comparison as a spiritual reflection, with the words “it is said.” It offers a lesson without establishing precisely how hungry Moses was or giving the sole cause of his hardship. In the account of Midian he drew water for the two women and withdrew to the shade. Here he bore travel and hunger in seeking knowledge. Both accounts furnish the reader with humility and patience. As for identifying the women’s father as Shuʿayb, it is a view held by commentators. The Qur’an does not name him in that story.
Psychological Outpourings
This is a different kind of test for the soul. On the earlier occasions Moses spoke against apparent wrongdoing, first a ship pierced and then a boy killed. Here he has no objection to setting the wall upright, which is a good deed. His question is about forgoing payment when food is needed. The third objection concerns a benefit that appears to have been missed. This is subtler, because a person may be able to accept a good deed and still ask, “Why did we not take something for it when we needed it?”
Al-Zamakhshari describes their situation: “They were in desperate need of food. Necessity drove them to a person’s last recourse for obtaining anything, which is to ask. They found no one willing to share with them. When he set the wall upright, Moses saw their deprivation and their pressing need and could not help saying ﴿قَالَ لَوْ شِئْتَ لَتَّخَذْتَ عَلَيْهِ أَجْراً﴾ (“[Moses] said, "If you wished, you could have taken for it a payment.”, Qur’an 18:77). He could have sought payment for his work so the two of them could recover their strength and relieve their need.” — Al-Kashshaf ʿan Haqaʾiq Ghawamid al-Tanzil — Mahmud ibn ʿUmar al-Zamakhshari.
Here is the mind of a hungry person who has been turned away. Moses sees a real need, without asking for comfort or luxury. They asked for food and found none. Then there was work that might have bought food, and al-Khidr let the opportunity pass. His words make sense under that pressure: ﴿لو شئت لاتخذت عليه أجرًا﴾ (“If you wished, you could have taken for it a payment.”, Qur’an 18:77). The question is why he did not take payment for putting up the wall.
There is a profound lesson about the mind here. Need presses on it and makes a person see possibilities in light of what they need at once. Moses sees hunger, an inhospitable town, and work that might have earned a wage. Al-Khidr sees two orphans, a treasure, a righteous father, and a distant outcome. Need may confine a person’s attention to what is immediately before them, and they may need faith to see farther.
On Moses’ words, Ibn ʿAshur writes: “﴿لَوْ شِئْتَ لَتَّخَذْتَ عَلَيْهِ أَجْرَاً﴾ (“If you wished, you could have taken for it a payment.”, Qur’an 18:77) is a reproach. ‘You had it in your power to set a wage for putting the wall upright, to be paid by whoever owned it from among the townspeople, rather than doing it for free. They did not fulfill the right of hospitality, and we need something to spend on ourselves.’ […] The reproach contains a question about why he did not stipulate payment for putting up the wall when they needed a wage. It is no reproach for the simple fact that he did it for free, since that is a good deed and there is no blame in it.” — Al-Tahrir wa-l-Tanwir — Muhammad al-Tahir Ibn ʿAshur.
This distinction clarifies what Moses was feeling. He has no quarrel with a good deed for being good. He takes issue with leaving the payment when they needed it and when the townspeople had been miserly. His question is gentler than his earlier ones. It remains a question after the condition, and for that reason it brings about their parting.
Pedagogical Outpourings
This verse teaches us to do work that may appear to be for the undeserving when it can protect a claim that is out of sight. Al-Khidr set a wall upright in a miserly town to protect the orphans’ property, without rewarding its people. Educators should be slow to judge a whole place by its worst inhabitants. There may be a good child in a failing school, an innocent and vulnerable person in a harsh home, or two orphans in a mean town whom Allah protects on account of the righteousness of their father.
The verse also teaches that asking for hospitality is not blameworthy when one needs it. The two asked the townspeople for food. Ibn al-ʿArabi writes: “The kind of asking involved here is a request for hospitality, which is either obligatory or a recommended Sunnah, as we have explained there. It is permissible to ask for it.” — Ahkam al-Qur’an — Abu Bakr Muhammad ibn ʿAbd Allah Ibn al-ʿArabi.
This answers anyone who thinks perfect reliance on Allah means never asking for food or for the hospitality one needs. Moses and al-Khidr both asked for food, and nothing about that detracted from them. Once the people refused, their meanness did not prevent al-Khidr from doing good where Allah intended it.
There is another lesson for educators here. The teaching came to an end because the third question broke the condition after Moses gave the other person grounds to part. It was the mildest question of the three. The gravity of what someone does may lie in where it falls in relation to a promise. Moses’ words here are gentler than what he said about the killing, yet they come after the condition ﴿إن سألتك عن شيء بعدها فلا تصاحبني﴾ (“If I should ask you about anything after this, then do not keep me as a companion”, Qur’an 18:76). That is why the two part. Education weighs an act in light of the agreement already in place.
Al-Qushayri writes: “When al-Khidr had set their wall upright and asked for no wage, Moses did not say, ‘You have done something forbidden.’ He said to him ﴿لَوْ شِئْتَ لَتَّخَذْتَ عَلَيْهِ أَجْراً﴾ (“If you wished, you could have taken for it a payment.”, Qur’an 18:77). That is, if you did not take anything for yourself, you could have taken it for our sake. To take it would have been better for us than to leave it. If their right had to be fulfilled, why have you let ours go unfulfilled?” — Lataʾif al-Isharat — ʿAbd al-Karim ibn Hawazin al-Qushayri.
This shows Moses’ courtesy even in the third breach. He did not call the deed wrong. He pointed to the practical benefit of payment. Even so, the agreement had become decisive. The gentlest question can end a companionship when it comes after a condition against questioning and one of the companions has made it their limit.
Contemporary Outpourings
This verse teaches that a society whose meanness is all we see may have orphans, treasures, and traces of righteous parents hidden within it. Those who work to put things right must not resort to collective revenge. Some townspeople may mistreat you, yet your work may protect a vulnerable person who had no part in the offense. Charitable, educational, and religious organizations can learn from this. Do not abandon the vulnerable because the people in power did wrong. Do not pull the wall down because the townspeople were miserly. Two orphans may have something to lose behind it.
In a materialistic world Moses’ question is an insistent one: “Why do we not take payment?” In many circumstances it is legitimate. A worker deserves a wage, and people should not take advantage of those who do good. The verse also teaches that some work cannot be valued by immediate payment, because it protects a right that will be exercised later or fulfills a trust no one knows about. Work without pay need not be a loss. Forgoing payment can be the wise choice when the work is done for Allah or to preserve the rights of someone who cannot pay.
For families, the verse gives fathers and mothers the good news that righteousness is a hidden inheritance. A righteous father may die without seeing what will happen to his children. Allah may keep something good for them out of their sight. The account of the treasure is particular to this story and offers no guarantee that every righteous person’s children will be spared poverty or trial. A sincere prayer, a lawful morsel, or a prostration in the depth of night may protect a child’s provision years later. The father’s righteousness here lives on beyond his children’s feelings about him. The Qur’an makes it a means by which the orphans’ treasure was protected.
In your own life there may be a treasure under a leaning wall without your knowing it. The wall may seem to be in the way when it is really a shelter. What looks like being deprived of provision through delay may be protection until you are ready. You may feel Allah has left you hungry in an inhospitable town while He is arranging for you another treasure you do not see. Read your life in those walls Allah put upright for you without your knowledge as well as in the morsel you were denied.
The verse remains a profound lesson in trusting Allah and refusing to rely on appearances alone. The townspeople refuse, the wall leans, al-Khidr puts it upright, and Moses sees a chance to earn something go by. The explanation will disclose two orphans, a treasure, a righteous father, and a merciful Lord behind it all. How often do we live through what the verse shows on the surface and only later understand its meaning? We are turned away in one place and protected in another, go hungry at one door and have a wall put upright over a treasure we do not know about. The heart learns that Allah’s gentleness can be at work unseen, even in a town that will open no door to a hungry traveler.
﴿فَانطَلَقَا حَتَّىٰ إِذَا أَتَيَا أَهْلَ قَرْيَةٍ اسْتَطْعَمَا أَهْلَهَا فَأَبَوْا أَن يُضَيِّفُوهُمَا فَوَجَدَا فِيهَا جِدَارًا يُرِيدُ أَن يَنقَضَّ فَأَقَامَهُ ۖ قَالَ لَوْ شِئْتَ لَاتَّخَذْتَ عَلَيْهِ أَجْرًا﴾ (77)
So they set out, until when they came to the people of a town, they asked its people for food, but they refused to offer them hospitality. And they found therein a wall about to collapse, so al-Khidh r restored it. [Moses] said, "If you wished, you could have taken for it a payment." (Qur’an 18:77)