Sahih Muslim , Hadith 2743

'Abdullah b. 'Umar reported that Allah's Messenger said: Three persons set out on a journey. They were overtaken by rain and they had to find protection in a mountain cave where at its mouth there fell a rock of that mountain and thus blocked them altogether. One of them said to the others: Look to your good deeds that you performed for the sake of Allah and then supplicate Allah, the Exalted, that He might rescue you (from this trouble). One of them said: 0 Allah, I had my parents who were old and my wife and my small children also. I tended the flock and when I came back to them in the evening, I milked them (the sheep, goats, cows, etc.) and first served that milk to my parents. One day I was obliged to go out to a distant place in search of fodder and I could not come back before evening and found them (the parents) asleep. I milked the animals as I used to milk and brought milk to them and stood by their heads avoiding to disturb them from sleep and I did not deem it advisable to serve milk to my children before serving them. My children wept near my feet. I remained there in that very state and my parents too until it was morning. And (0 Allah) if Thou art aware that I did this in order to seek Thine pleasure, grant us riddance from this trouble. (The rock slipped a bit) that they could see the sky. The second one said: 0 Allah, I had a female cousin whom I loved more than the men love the women. I wanted to have sexual intercourse with her; she refused but on the condition of getting one hundred dinirs. It was with very great difficulty that I could collect one hundred dinirs and then paid them to her and when I was going to have a sexual intercourse with her, that she said: Servant of Allah, fear Allah and do not break the seal (of chastity) but by lawful means. I got up. 0 Allah, if Thou art aware that I did this in order to seek Thine pleasure, rid us from this trouble. The situation was somewhat eased for them. The third one said: Allah, I employed a workman for a measure of rice. After he had finished his work I gave him his dues (in the form of) a measure of rice, but he did not accept them. I used these rice as seeds, and that gave a bumper crop and I became rich enough to have cows and flocks (in my possession). He came to me and said: Fear Allah, and commit no crueltv upon me in regard to my dues. I said to him: Takeaway this flock of cows and sheep. He said: Fear Allah and do not make a fun of me. I said: I am not making a fun of you. You take the cows and the flocks. So he took them. 0 Allah, if Thou art aware that I did it for Thine pleasure, case the situation for us. And Allah relieved them from the rest of the trouble.

حَدَّثَنِي مُحَمَّدُ بْنُ إِسْحَاقَ الْمُسَيَّبِيُّ، حَدَّثَنِي أَنَسٌ، - يَعْنِي ابْنَ عِيَاضٍ أَبَا ضَمْرَةَ - عَنْ مُوسَى بْنِ عُقْبَةَ، عَنْ نَافِعٍ، عَنْ عَبْدِ اللَّهِ بْنِ عُمَرَ، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم أَنَّهُ قَالَ ‏"‏ بَيْنَمَا ثَلاَثَةُ نَفَرٍ يَتَمَشَّوْنَ أَخَذَهُمُ الْمَطَرُ فَأَوَوْا إِلَى غَارٍ فِي جَبَلٍ فَانْحَطَّتْ عَلَى فَمِ غَارِهِمْ صَخْرَةٌ مِنَ الْجَبَلِ فَانْطَبَقَتْ عَلَيْهِمْ فَقَالَ بَعْضُهُمْ لِبَعْضٍ انْظُرُوا أَعْمَالاً عَمِلْتُمُوهَا صَالِحَةً لِلَّهِ فَادْعُوا اللَّهَ تَعَالَى بِهَا لَعَلَّ اللَّهَ يَفْرُجُهَا عَنْكُمْ ‏.‏ فَقَالَ أَحَدُهُمُ اللَّهُمَّ إِنَّهُ كَانَ لِي وَالِدَانِ شَيْخَانِ كَبِيرَانِ وَامْرَأَتِي وَلِيَ صِبْيَةٌ صِغَارٌ أَرْعَى عَلَيْهِمْ فَإِذَا أَرَحْتُ عَلَيْهِمْ حَلَبْتُ فَبَدَأْتُ بِوَالِدَىَّ فَسَقَيْتُهُمَا قَبْلَ بَنِيَّ وَأَنَّهُ نَأَى بِي ذَاتَ يَوْمٍ الشَّجَرُ فَلَمْ آتِ حَتَّى أَمْسَيْتُ فَوَجَدْتُهُمَا قَدْ نَامَا فَحَلَبْتُ كَمَا كُنْتُ أَحْلُبُ فَجِئْتُ بِالْحِلاَبِ فَقُمْتُ عِنْدَ رُءُوسِهِمَا أَكْرَهُ أَنْ أُوقِظَهُمَا مِنْ نَوْمِهِمَا وَأَكْرَهُ أَنْ أَسْقِيَ الصِّبْيَةَ قَبْلَهُمَا وَالصِّبْيَةُ يَتَضَاغَوْنَ عِنْدَ قَدَمَىَّ فَلَمْ يَزَلْ ذَلِكَ دَأْبِي وَدَأْبَهُمْ حَتَّى طَلَعَ الْفَجْرُ فَإِنْ كُنْتَ تَعْلَمُ أَنِّي فَعَلْتُ ذَلِكَ ابْتِغَاءَ وَجْهِكَ فَافْرُجْ لَنَا مِنْهَا فُرْجَةً نَرَى مِنْهَا السَّمَاءَ ‏.‏ فَفَرَجَ اللَّهُ مِنْهَا فُرْجَةً فَرَأَوْا مِنْهَا السَّمَاءَ ‏.‏ وَقَالَ الآخَرُ اللَّهُمَّ إِنَّهُ كَانَتْ لِيَ ابْنَةُ عَمٍّ أَحْبَبْتُهَا كَأَشَدِّ مَا يُحِبُّ الرِّجَالُ النِّسَاءَ وَطَلَبْتُ إِلَيْهَا نَفْسَهَا فَأَبَتْ حَتَّى آتِيَهَا بِمِائَةِ دِينَارٍ فَتَعِبْتُ حَتَّى جَمَعْتُ مِائَةَ دِينَارٍ فَجِئْتُهَا بِهَا فَلَمَّا وَقَعْتُ بَيْنَ رِجْلَيْهَا قَالَتْ يَا عَبْدَ اللَّهِ اتَّقِ اللَّهَ وَلاَ تَفْتَحِ الْخَاتَمَ إِلاَّ بِحَقِّهِ ‏.‏ فَقُمْتُ عَنْهَا فَإِنْ كُنْتَ تَعْلَمُ أَنِّي فَعَلْتُ ذَلِكَ ابْتِغَاءَ وَجْهِكَ فَافْرُجْ لَنَا مِنْهَا فُرْجَةً ‏.‏ فَفَرَجَ لَهُمْ ‏.‏ وَقَالَ الآخَرُ اللَّهُمَّ إِنِّي كُنْتُ اسْتَأْجَرْتُ أَجِيرًا بِفَرَقِ أَرُزٍّ فَلَمَّا قَضَى عَمَلَهُ قَالَ أَعْطِنِي حَقِّي ‏.‏ فَعَرَضْتُ عَلَيْهِ فَرَقَهُ فَرَغِبَ عَنْهُ فَلَمْ أَزَلْ أَزْرَعُهُ حَتَّى جَمَعْتُ مِنْهُ بَقَرًا وَرِعَاءَهَا فَجَاءَنِي فَقَالَ اتَّقِ اللَّهَ وَلاَ تَظْلِمْنِي حَقِّي ‏.‏ قُلْتُ اذْهَبْ إِلَى تِلْكَ الْبَقَرِ وَرِعَائِهَا فَخُذْهَا ‏.‏ فَقَالَ اتَّقِ اللَّهَ وَلاَ تَسْتَهْزِئْ بِي ‏.‏ فَقُلْتُ إِنِّي لاَ أَسْتَهْزِئُ بِكَ خُذْ ذَلِكَ الْبَقَرَ وَرِعَاءَهَا ‏.‏ فَأَخَذَهُ فَذَهَبَ بِهِ فَإِنْ كُنْتَ تَعْلَمُ أَنِّي فَعَلْتُ ذَلِكَ ابْتِغَاءَ وَجْهِكَ فَافْرُجْ لَنَا مَا بَقِيَ ‏.‏ فَفَرَجَ اللَّهُ مَا بَقِيَ ‏.‏

sunnah.com

This hadith has been transmitted on the authority of Musa b. 'Uqba but with a slight variation of wording.

وَحَدَّثَنَا إِسْحَاقُ بْنُ مَنْصُورٍ، وَعَبْدُ بْنُ حُمَيْدٍ، قَالاَ أَخْبَرَنَا أَبُو عَاصِمٍ، عَنِ ابْنِ، جُرَيْجٍ أَخْبَرَنِي مُوسَى بْنُ عُقْبَةَ، ح وَحَدَّثَنِي سُوَيْدُ بْنُ سَعِيدٍ، حَدَّثَنَا عَلِيُّ بْنُ مُسْهِرٍ، عَنْ عُبَيْدِ اللَّهِ، ح وَحَدَّثَنِي أَبُو كُرَيْبٍ، وَمُحَمَّدُ بْنُ طَرِيفٍ الْبَجَلِيُّ، قَالاَ حَدَّثَنَا ابْنُ فُضَيْلٍ، حَدَّثَنَا أَبِي وَرَقَبَةُ بْنُ مَسْقَلَةَ، ح وَحَدَّثَنِي زُهَيْرُ بْنُ حَرْبٍ، وَحَسَنٌ الْحُلْوَانِيُّ، وَعَبْدُ بْنُ حُمَيْدٍ، قَالُوا حَدَّثَنَا يَعْقُوبُ، - يَعْنُونَ ابْنَ إِبْرَاهِيمَ بْنِ سَعْدٍ - حَدَّثَنَا أَبِي، عَنْ صَالِحِ بْنِ كَيْسَانَ، كُلُّهُمْ عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، عَنِ النَّبِيِّ صلى الله عليه وسلم بِمَعْنَى حَدِيثِ أَبِي ضَمْرَةَ عَنْ مُوسَى بْنِ عُقْبَةَ وَزَادُوا فِي حَدِيثِهِمْ ‏"‏ وَخَرَجُوا يَمْشُونَ ‏"‏ ‏.‏ وَفِي حَدِيثِ صَالِحٍ ‏"‏ يَتَمَاشَوْنَ ‏"‏ ‏.‏ إِلاَّ عُبَيْدَ اللَّهِ فَإِنَّ فِي حَدِيثِهِ ‏"‏ وَخَرَجُوا ‏"‏ ‏.‏ وَلَمْ يَذْكُرْ بَعْدَهَا شَيْئًا ‏.‏

sunnah.com

Abdullah b 'Umar reported: I heard Allah's Messenger as saying: Three persons belonging to the earlier Ummahs set out on a journey until they had to spend a night in a cave. The rest of the hadith is the same and the additional words are:" A person amongst them said: O Allah, I had my aged parents and I served them milk before I (served that) to my wife, children and my servants." And in case of the second one, the words are: "She avoided me until she was hard pressed because of famine and she came to me and I gave her one hundred and twenty dinars." And in case of the third one (the words are):" I invested his wages, and it brought profit and, as a result thereof, the merchandise increased and there was an abundance of goods." And he (the narrator said) that they got out of the cave and began to walk.

حَدَّثَنِي مُحَمَّدُ بْنُ سَهْلٍ التَّمِيمِيُّ، وَعَبْدُ اللَّهِ بْنُ عَبْدِ الرَّحْمَنِ بْنِ بَهْرَامَ، وَأَبُو بَكْرِ بْنُ إِسْحَاقَ قَالَ ابْنُ سَهْلٍ حَدَّثَنَا وَقَالَ الآخَرَانِ، أَخْبَرَنَا أَبُو الْيَمَانِ، أَخْبَرَنَا شُعَيْبٌ، عَنِ الزُّهْرِيِّ، أَخْبَرَنِي سَالِمُ بْنُ عَبْدِ اللَّهِ، أَنَّ عَبْدَ اللَّهِ بْنَ عُمَرَ، قَالَ سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏"‏ انْطَلَقَ ثَلاَثَةُ رَهْطٍ مِمَّنْ كَانَ قَبْلَكُمْ حَتَّى آوَاهُمُ الْمَبِيتُ إِلَى غَارٍ ‏"‏ ‏.‏ وَاقْتَصَّ الْحَدِيثَ بِمَعْنَى حَدِيثِ نَافِعٍ عَنِ ابْنِ عُمَرَ غَيْرَ أَنَّهُ قَالَ قَالَ رَجُلٌ مِنْهُمُ ‏"‏ اللَّهُمَّ كَانَ لِي أَبَوَانِ شَيْخَانِ كَبِيرَانِ فَكُنْتُ لاَ أَغْبُقُ قَبْلَهُمَا أَهْلاً وَلاَ مَالاً ‏"‏ ‏.‏ وَقَالَ ‏"‏ فَامْتَنَعَتْ مِنِّي حَتَّى أَلَمَّتْ بِهَا سَنَةٌ مِنَ السِّنِينَ فَجَاءَتْنِي فَأَعْطَيْتُهَا عِشْرِينَ وَمِائَةَ دِينَارٍ ‏"‏ ‏.‏ وَقَالَ ‏"‏ فَثَمَّرْتُ أَجْرَهُ حَتَّى كَثُرَتْ مِنْهُ الأَمْوَالُ فَارْتَعَجَتْ ‏"‏ ‏.‏ وَقَالَ ‏"‏ فَخَرَجُوا مِنَ الْغَارِ يَمْشُونَ

sunnah.com