Abdullah bin Umar reported,

The Messenger of Allah ﷺ said, "While three men were walking along, rain caught them, so they took shelter in a cave in a mountain. A boulder fell from the mountain onto the mouth of their cave and sealed them inside.They said to one another, 'Think of righteous deeds you have done for the sake of Allah, and call upon Allah by them, perhaps Allah will relieve you from this.'One of them said, 'O Allah, I had two elderly parents, along with my wife, and I had small children whom I tended flocks to support. When I would return 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 away, and I did not return until evening had fallen. I found that my parents had already gone to sleep. I milked as I usually did and brought the milk vessel, then stood at their heads, reluctant to wake them from their sleep, and reluctant to give the children to drink before them, while the children cried out at my feet. This remained my situation and theirs until dawn broke. If You know that I did that seeking Your face, then relieve us with 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 intensely as men can love women. I sought her for myself, but she refused unless I brought her one hundred Dinar. I toiled until I gathered one hundred Dinar 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 rightful means.' So I got up and left her. If You know that I did that seeking Your face, then relieve us with an opening.'So Allah opened more for them.The third said, 'O Allah, I once hired a worker for a measure of rice. When he finished his work, he said, 'Give me my due.' I offered him his measure, but he refused it. I kept planting it until from it 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. If You know that I did that seeking Your face, then relieve us of what remains.'So Allah relieved them of what remained."

Azami 8286

Sahih

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

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

الأعظمي 8286صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
News of the ancients
Section
Story of the three companions of the cave
Numbering
Jami al-Kamil 8286 (2nd edition)
Azami 8286