Sahih al-Bukhari, Volume 4, Book 56, Hadith 671 (USC-MSA) ⓘ
Narrated Ibn `Umar: Allah's Messenger said, "Once three persons (from the previous nations) were traveling, and suddenly it started raining and they took shelter in a cave. The entrance of the cave got closed while they were inside. They said to each other, 'O you! Nothing can save you except the truth, so each of you should ask Allah's Help by referring to such a deed as he thinks he did sincerely (i.e. just for gaining Allah's Pleasure).' So one of them said, 'O Allah! You know that I had a laborer who worked for me for one Faraq (i.e. three Sas) of rice, but he departed, leaving it (i.e. his wages). I sowed that Faraq of rice and with its yield I bought cows (for him). Later on when he came to me asking for his wages, I said (to him), 'Go to those cows and drive them away.' He said to me, 'But you have to pay me only a Faraq of rice,' I said to him, 'Go to those cows and take them, for they are the product of that Faraq (of rice).' So he drove them. O Allah! If you consider that I did that for fear of You, then please remove the rock.' The rock shifted a bit from the mouth of the cave. The second one said, 'O Allah, You know that I had old parents whom I used to provide with the milk of my sheep every night. One night I was delayed and when I came, they had slept, while my wife and children were crying with hunger. I used not to let them (i.e. my family) drink unless my parents had drunk first. So I disliked to wake them up and also disliked that they should sleep without drinking it, I kept on waiting (for them to wake) till it dawned. O Allah! If You consider that I did that for fear of you, then please remove the rock.' So the rock shifted and they could see the sky through it. The (third) one said, 'O Allah! You know that I had a cousin (i.e. my paternal uncle's daughter) who was most beloved to me and I sought to seduce her, but she refused, unless I paid her one-hundred Dinars (i.e. gold pieces). So I collected the amount and brought it to her, and she allowed me to sleep with her. But when I sat between her legs, she said, 'Be afraid of Allah, and do not deflower me but legally. 'I got up and left the hundred Dinars (for her). O Allah! If You consider that I did that for fear of you than please remove the rock. So Allah saved them and they came out (of the cave)."
حَدَّثَنَا إِسْمَاعِيلُ بْنُ خَلِيلٍ، أَخْبَرَنَا عَلِيُّ بْنُ مُسْهِرٍ، عَنْ عُبَيْدِ اللَّهِ بْنِ عُمَرَ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ ـ رضى الله عنهما ـ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ " بَيْنَمَا ثَلاَثَةُ نَفَرٍ مِمَّنْ كَانَ قَبْلَكُمْ يَمْشُونَ إِذْ أَصَابَهُمْ مَطَرٌ، فَأَوَوْا إِلَى غَارٍ، فَانْطَبَقَ عَلَيْهِمْ، فَقَالَ بَعْضُهُمْ لِبَعْضٍ إِنَّهُ وَاللَّهِ يَا هَؤُلاَءِ لاَ يُنْجِيكُمْ إِلاَّ الصِّدْقُ، فَلْيَدْعُ كُلُّ رَجُلٍ مِنْكُمْ بِمَا يَعْلَمُ أَنَّهُ قَدْ صَدَقَ فِيهِ. فَقَالَ وَاحِدٌ مِنْهُمُ اللَّهُمَّ إِنْ كُنْتَ تَعْلَمُ أَنَّهُ كَانَ لِي أَجِيرٌ عَمِلَ لِي عَلَى فَرَقٍ مِنْ أَرُزٍّ، فَذَهَبَ وَتَرَكَهُ، وَأَنِّي عَمَدْتُ إِلَى ذَلِكَ الْفَرَقِ فَزَرَعْتُهُ، فَصَارَ مِنْ أَمْرِهِ أَنِّي اشْتَرَيْتُ مِنْهُ بَقَرًا، وَأَنَّهُ أَتَانِي يَطْلُبُ أَجْرَهُ فَقُلْتُ اعْمِدْ إِلَى تِلْكَ الْبَقَرِ. فَسُقْهَا، فَقَالَ لِي إِنَّمَا لِي عِنْدَكَ فَرَقٌ مِنْ أَرُزٍّ. فَقُلْتُ لَهُ اعْمِدْ إِلَى تِلْكَ الْبَقَرِ فَإِنَّهَا مِنْ ذَلِكَ الْفَرَقِ، فَسَاقَهَا، فَإِنْ كُنْتَ تَعْلَمُ أَنِّي فَعَلْتُ ذَلِكَ مِنْ خَشْيَتِكَ، فَفَرِّجْ عَنَّا. فَانْسَاحَتْ عَنْهُمُ الصَّخْرَةُ. فَقَالَ الآخَرُ اللَّهُمَّ إِنْ كُنْتَ تَعْلَمُ أَنَّهُ كَانَ لِي أَبَوَانِ شَيْخَانِ كَبِيرَانِ، فَكُنْتُ آتِيهِمَا كُلَّ لَيْلَةٍ بِلَبَنِ غَنَمٍ لِي، فَأَبْطَأْتُ عَلَيْهِمَا لَيْلَةً فَجِئْتُ وَقَدْ رَقَدَا وَأَهْلِي وَعِيَالِي يَتَضَاغَوْنَ مِنَ الْجُوعِ، فَكُنْتُ لاَ أَسْقِيهِمْ حَتَّى يَشْرَبَ أَبَوَاىَ، فَكَرِهْتُ أَنْ أُوقِظَهُمَا، وَكَرِهْتُ أَنْ أَدَعَهُمَا، فَيَسْتَكِنَّا لِشَرْبَتِهِمَا، فَلَمْ أَزَلْ أَنْتَظِرُ حَتَّى طَلَعَ الْفَجْرُ، فَإِنْ كُنْتَ تَعْلَمُ أَنِّي فَعَلْتُ ذَلِكَ مِنْ خَشْيَتِكَ، فَفَرِّجْ عَنَّا. فَانْسَاحَتْ عَنْهُمُ الصَّخْرَةُ، حَتَّى نَظَرُوا إِلَى السَّمَاءِ. فَقَالَ الآخَرُ اللَّهُمَّ إِنْ كُنْتَ تَعْلَمُ أَنَّهُ كَانَ لِي ابْنَةُ عَمٍّ مِنْ أَحَبِّ النَّاسِ إِلَىَّ، وَأَنِّي رَاوَدْتُهَا عَنْ نَفْسِهَا فَأَبَتْ إِلاَّ أَنْ آتِيَهَا بِمِائَةِ دِينَارٍ، فَطَلَبْتُهَا حَتَّى قَدَرْتُ، فَأَتَيْتُهَا بِهَا فَدَفَعْتُهَا إِلَيْهَا، فَأَمْكَنَتْنِي مِنْ نَفْسِهَا، فَلَمَّا قَعَدْتُ بَيْنَ رِجْلَيْهَا، فَقَالَتِ اتَّقِ اللَّهَ وَلاَ تَفُضَّ الْخَاتَمَ إِلاَّ بِحَقِّهِ. فَقُمْتُ وَتَرَكْتُ الْمِائَةَ دِينَارٍ، فَإِنْ كُنْتَ تَعْلَمُ أَنِّي فَعَلْتُ ذَلِكَ مِنْ خَشْيَتِكَ فَفَرِّجْ عَنَّا. فَفَرَّجَ اللَّهُ عَنْهُمْ فَخَرَجُوا " .
also referenced under: Book 60, Hadith 132 (In-Book) & Hadith 3465 (DarusSalam)