Abdullah bin Umar reported,

The Messenger of Allah ﷺ said, "While three men were walking along, they were caught in the rain, so they took shelter in a cave in a mountain. A boulder rolled down from the mountain and sealed the mouth of their cave, trapping them inside.They said to one another, 'Look back at the righteous deeds you have done for the sake of Allah, and call upon Allah Almighty by them. Perhaps Allah will relieve you of this rock.'One of them said, 'O Allah, I had two elderly parents and a wife, and I had small children for whom I tended my flock. When I would return to them in the evening, I would milk the animals 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 the animals as I usually did, brought the milk vessel, and stood by their heads. I disliked waking them from their sleep, but I also disliked giving the children to drink before them, while the children were crying out in hunger at my feet. This remained my state and theirs until dawn broke. If You know that I did this seeking Your face, then relieve us of some of this rock so that we may see the sky.' So Allah opened a gap in it, and they could see the sky through it.The second man said, 'O Allah, I had a cousin whom I loved as deeply as men love women. I sought to lie with her, but she refused unless I brought her one hundred Dinar. So I labored hard until I had gathered one hundred Dinar, and I 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 this seeking Your face, then relieve us of some of this rock.' So He relieved them of more of it.The third man said, 'O Allah, I once hired a worker for a measure of rice. When he completed his work, he said, Give me my wages. I offered him his measure, but he refused it. So I kept planting it until I had gathered from it a herd of cattle and their herdsmen. Then he came back 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 replied, I am not mocking you. Take those cattle and their herdsmen. So he took them and went away. If You know that I did this seeking Your face, then relieve us of what remains.' So Allah relieved them of what remained."

Azami 10968

Sahih

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

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

الأعظمي 10968صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Supplications, remembrances, and prayer upon the chosen Prophet ﷺ
Chapter
Legitimate means of seeking nearness in supplication
Section
Seeking nearness to Allah through righteous deeds
Numbering
Jami al-Kamil 10968 (2nd edition)
Azami 10968