Abdullah bin Umar reported,

The Messenger of Allah ﷺ said, "While three men were walking, rain caught them, so they took shelter in a cave in a mountain. A boulder rolled down from the mountain onto the mouth of their cave and sealed them inside. They said to one another, 'Look to the righteous deeds you have done for Allah, and call upon Allah, the Exalted, by means of them. Perhaps Allah will relieve you of this.'One of them said, 'O Allah, I had two elderly parents and a wife, and I had small children whom I supported by tending livestock. When I returned to them in the evening, I would milk and begin with my parents, giving them to drink before my children. One day the search for pasture took me far afield, and I did not return until evening had set in. I found that they had already fallen asleep. I milked as I always did, then came with the milk and stood by their heads, hating to wake them from their sleep, yet hating also to give my children to drink before them. My children were crying out at my feet. This continued to be my state and theirs until dawn broke. If You know that I did this seeking Your face, then grant us relief from this boulder, an opening through which we may see the sky.' So Allah opened a gap, and they could see the sky through it.The second said, 'O Allah, I had a cousin whom I loved as deeply as a man can love a woman. I sought to lie with her, but she refused unless I brought her one hundred Dinars. So I labored until I had gathered one hundred Dinars and brought them to her. When I sat between her legs, she said, "Abdullah, fear Allah, and do not break the seal except by its right." So I rose from her. If You know that I did this seeking Your face, then grant us relief from this.' So He granted them further relief.The third said, 'O Allah, I hired a laborer for a measure of rice. When he finished his work, he said, "Give me my wages." I offered him his measure, but he refused it. So I kept planting it until from its yield I had gathered cattle and their herdsmen. Then he came to me and said, "Fear Allah, and do not wrong me of my due." I said, "Go to those cattle and their herdsmen and take them." He said, "Fear Allah, and do not mock me." I said, "I am not mocking you. Take those cattle and their herdsmen." So he took them and went away with them. If You know that I did this seeking Your face, then grant us relief from what remains.' So Allah relieved them of what remained."

Muslim 6949

Sahih

حدثني محمد بن إسحق المسيبي حدثني أنس يعني ابن عياض أبا ضمرة عن موسى بن عقبة عن نافع

عن عبد الله بن عمر

عن رسول الله ﷺ أنه قال بينما ثلاثة نفر يتمشون أخذهم المطر فأووا إلى غار في جبل فانحطت على فم غارهم صخرة من الجبل فانطبقت عليهم فقال بعضهم لبعض انظروا أعمالا عملتموها صالحة لله فادعوا الله تعالى بها لعل الله يفرجها عنكم فقال أحدهم اللهم إنه كان لي والدان شيخان كبيران وامرأتي ولي صبية صغار أرعى عليهم فإذا أرحت عليهم حلبت فبدأت بوالدي فسقيتهما قبل بني وأنه نأى بي ذات يوم الشجر فلم آت حتى أمسيت فوجدتهما قد ناما فحلبت كما كنت أحلب فجئت بالحلاب فقمت عند رءوسهما أكره أن أوقظهما من نومهما وأكره أن أسقي الصبية قبلهما والصبية يتضاغون عند قدمي فلم يزل ذلك دأبي ودأبهم حتى طلع الفجر فإن كنت تعلم أني فعلت ذلك ابتغاء وجهك فافرج لنا منها فرجة نرى منها السماء ففرج الله منها فرجة فرأوا منها السماء وقال الآخر اللهم إنه كانت لي ابنة عم أحببتها كأشد ما يحب الرجال النساء وطلبت إليها نفسها فأبت حتى آتيها بمائة دينار فتعبت حتى جمعت مائة دينار فجئتها بها فلما وقعت بين رجليها قالت يا عبد الله اتق الله ولا تفتح الخاتم إلا بحقه فقمت عنها فإن كنت تعلم أني فعلت ذلك ابتغاء وجهك فافرج لنا منها فرجة ففرج لهم وقال الآخر اللهم إني كنت استأجرت أجيرا بفرق أرز فلما قضى عمله قال أعطني حقي فعرضت عليه فرقه فرغب عنه فلم أزل أزرعه حتى جمعت منه بقرا ورعاءها فجاءني فقال اتق الله ولا تظلمني حقي قلت اذهب إلى تلك البقر ورعائها فخذها فقال اتق الله ولا تستهزئ بي فقلت إني لا أستهزئ بك خذ ذلك البقر ورعاءها فأخذه فذهب به فإن كنت تعلم أني فعلت ذلك ابتغاء وجهك فافرج لنا ما بقي ففرج الله ما بقي

مسلم 6949صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Softening of hearts
Chapter
Story of the three companions of the cave and seeking nearness to Allah through righteous deeds
Numbering
Darussalam 6949
Muslim 6949