Where the story is told
The parable is in Surah al-Kahf, Quran 18:32-44. Allah tells the Prophet ﷺ to present to the people an example of two men. The Quran calls it an example, and does not say who the two men were or when they lived.
It comes after the verses in which Allah tells the Prophet ﷺ to keep himself patient with those who call upon their Lord morning and evening, and not to let his eyes pass beyond them, wanting the adornments of worldly life (Quran 18:28). The parable shows how misleading those adornments can be.
The two gardens
Allah gave one of the two men two gardens of grapevines, bordered with palm trees, with crops between them. Each garden gave its fruit and did not fall short in anything, and Allah made a river gush forth between them (Quran 18:32-33).
The story begins with a picture of plenty. Everything the man had was a gift from Allah, and the gift was given to him as a test of how he would respond.
The boast
The man had fruit, and while speaking with his companion he said, in the meaning of the verse, that he was greater than him in wealth and mightier in numbers of men (Quran 18:34).
He then entered his garden while being unjust to himself. He said that he did not think this garden would ever perish, and that he did not think the Hour would come. He added that even if he were returned to his Lord, he would surely find something better than this (Quran 18:35-36). His wrong was not owning a garden. It was forgetting the One who gave it, and feeling safe from loss and from the Hereafter.
The believer's advice
His companion answered him while they were speaking. He asked whether he had disbelieved in the One who created him from dust, then from a drop, and then shaped him as a man (Quran 18:37). The companion said that Allah is his Lord and that he does not associate anyone with his Lord (Quran 18:38).
He also asked why, when the man entered his garden, he did not say "What Allah has willed has happened; there is no power except in Allah" (Quran 18:39). He said that even though the man saw him with less wealth and fewer children, it may be that his Lord would give him something better than the garden, and would send a calamity from the sky upon the garden so that it became a barren, smooth ground, or its water would sink into the earth so that the man could never find it (Quran 18:39-41).
The advice is gentle and clear. He did not boast of his own faith. He directed his companion back to gratitude, to the Creator and to the reality of the Hereafter.
The ruin
Then the man's fruits were encompassed by ruin. He began turning his hands over in regret for what he had spent on the garden, while it lay collapsed on its trellises, and he said, "Oh, I wish I had not associated anyone with my Lord" (Quran 18:42).
The Quran says that he had no group to help him other than Allah, and that he could not defend himself (Quran 18:43). It ends the parable by saying that the authority is for Allah, the Truth, and that He is best in reward and best in outcome (Quran 18:44).
The link to 18:45-46 and what the Quran does not tell us
The next verses explain the meaning of the parable. The life of this world is like rain that Allah sends down, and the plants of the earth mix with it and then become dry remnants scattered by the winds, and Allah has power over all things (Quran 18:45). Wealth and children are an adornment of the life of this world, but the enduring good deeds are better with your Lord in reward and better in hope (Quran 18:46).
The Quran does not say who the two men were, where the gardens were or when this happened. It does not describe what exactly the calamity from the sky was, beyond saying that the fruits were encompassed by ruin. Some books give names and detailed stories, but these are not in the Quran or in authentic hadith, so they are not included here.
Lessons from this story
- Wealth is a trust from Allah and a test. It is a reason for gratitude, not for boasting over others.
- Saying "What Allah has willed has happened; there is no power except in Allah" reminds the heart that every blessing comes from Him.
- The man's real mistake was feeling secure and forgetting the Hereafter. What we own can be taken away in a short time.
- The believing companion gave advice with kindness and clarity, and he stayed humble even when he had less than his friend.
- The enduring good deeds, such as prayer, charity and remembrance of Allah, last longer than any garden or any amount of wealth.
General information for learning, not a fatwa. For your own situation, ask a qualified scholar.