Jabir bin Abdullah reported,

The Messenger of Allah ﷺ used to teach us the prayer of seeking guidance (istikharah) in all matters, just as he would teach us a surah from the Quran. He would say, "When any of you is concerned about a matter, let him pray two units of prayer other than the obligatory prayer, then say, 'O Allah, I seek Your guidance through Your knowledge, and I seek Your power through Your might, and I ask You from Your immense bounty. For You are able and I am not, You know and I do not, and You are the Knower of all that is hidden. O Allah, if You know that this matter is good for me in my religion, my livelihood, and the outcome of my affairs,' or he said, 'in the immediate and long-term consequences of my affairs, then decree it for me, make it easy for me, and bless me in it. And if You know that this matter is evil for me in my religion, my livelihood, and the outcome of my affairs,' or he said, 'in the immediate and long-term consequences of my affairs, then turn it away from me and turn me away from it, and decree for me what is good wherever it may be, then make me content with it.'"He said, and he should name his need.

Azami 251

Sahih

عن جابر بن عبد الله قال

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

الأعظمي 251صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Faith in Allah عز وجل
Section
Affirmation of the knowledge of Allah the Exalted
Numbering
Jami al-Kamil 251 (2nd edition)
Azami 251