"So they set out, until when they met a boy, he killed him... 'And as for the boy, his parents were believers, and we feared that he would overburden them by transgression and disbelief. So we intended that their Lord should substitute for them one better than him... '"
What the verse says
Khidr — a servant of Allah given special divine knowledge — kills an innocent child. The explanation given is that Allah foresaw the boy would grow up to be a transgressor and disbeliever, and that his death was therefore merciful to his parents, who would be spared the anguish of a wicked son. A replacement child, better in character, is promised.
Why this is a problem
The boy has done nothing wrong. He is killed entirely on the basis of foreknowledge about acts he has not yet committed and choices he has not yet made. Every deontological and rights-based moral framework rejects punishment for predicted future behavior; the Khidr episode is most coherently criticized on these grounds. The boy had not yet sinned; he had not yet chosen transgression; he had not yet disbelieved. He was killed for what someone else knew he would do — which means he was killed before he had any opportunity to do otherwise.
This episode raises a direct contradiction within Islamic theology's treatment of free will and divine foreknowledge. If Allah knows the boy will sin, the question is whether the boy's future choices are genuinely free. If they are free, why is he killed before he has the opportunity to exercise them? If they are not free — if his sinful path is fixed — then he is being killed for a destiny he had no capacity to avoid, which collapses the moral framework that makes punishment coherent. The verse provides no resolution to this dilemma; it presents the killing as simply justified by divine foreknowledge.
The Muslim response
Classical Muslim commentators, including Ibn Kathir, al-Qurtubi, and al-Tabari, explain the Khidr episode not as a model for human behavior but as a demonstration of divine wisdom operating at a level inaccessible to ordinary human moral reasoning. The story is explicitly set up as a test of Moses — a prophet — who struggles to understand Khidr's actions, suggesting that even prophets cannot comprehend the full scope of divine wisdom. The episode's theological purpose is not to establish a principle that humans may kill others on the basis of foreknowledge; it is to humble human moral certainty and demonstrate that divine providence operates in ways beyond human comprehension. The dominant scholarly view holds that the boy is not punished at all: a child who dies before the age of accountability (taklif/bulugh) dies morally non-liable and, on the majority Sunni position, enters Paradise, so Khidr's act is a mercy to the boy himself — foreclosing his future damnation rather than penalizing him. Al-Ghazali in Ihya Ulum al-Din uses the Khidr story to illustrate the distinction between the apparent level of reality (zahir) and the deeper level (batin) that only special divine knowledge accesses. On the free will problem, Ash'arite theologians argue that Allah's foreknowledge does not compel human choices — the boy would genuinely have sinned freely; Khidr's intervention was an expression of divine mercy that prevented a greater harm, operating within the framework of divine sovereignty over life and death that belongs exclusively to Allah and His specially authorized agents, not to ordinary humans.
Why it fails
The "hidden divine knowledge" argument is unfalsifiable: any act can be defended as serving purposes only God knows, which is exactly the epistemic move that has historically licensed religious violence. The theological lesson sits awkwardly with the moral framework Islam elsewhere insists on — the Quran's judicial verses require actual offense before punishment, not predicted future offense. A defender can rightly distinguish God's prerogative over the timing of death, which never required a proven offense (as with infant mortality), from judicial punishment in a court, which does; the offense-before-punishment standard governs the latter, not the former. The genuine residue is that the text gives foreknowledge of future sin as the stated rationale for the killing, which keeps the act entangled with the unresolved dilemma over whether the boy's foreseen sin was genuinely free — and thus whether it was ever truly his to commit. If divine foreknowledge of acts not yet chosen can ground the taking of a presently-innocent life, the basis for claiming that divine justice requires actual human agency before punishment is seriously weakened. The Khidr episode is preserved in canonical scripture and presented approvingly, which means its logic is available to anyone who claims special divine knowledge about another person's future behavior.