Jabir bin Abdullah reported,

The Messenger of Allah ﷺ used to teach his companions to seek guidance through istikharah in all matters, just as he taught them a surah from the Quran. He would say, "When one 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 enabling through Your power, and I ask You from Your great bounty. For You are able and I am not, You know and I do not, and You are the Knower of the unseen. O Allah, if You know that this matter,' and he names it specifically, 'is good for me in the immediate and long-term affairs of my life,'" or he said, "'in my religion, my livelihood, and the outcome of my affairs, then decree it for me, make it easy for me, and bless me in it. O Allah, and if You know that it is bad for me in my religion, my livelihood, and the outcome of my affairs,'" or he said, "'in the immediate and long-term affairs of my life, then turn me away from it, and decree for me what is good wherever it may be, then make me content with it.'"

Bukhari 7390

Sahih

حدثني إبراهيم بن المنذر حدثنا معن بن عيسى حدثني عبد الرحمن بن أبي الموالي قال سمعت محمد بن المنكدر يحدث عبد الله بن الحسن يقول

أخبرني جابر بن عبد الله السلمي قال

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

البخاري 7390صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Tawhid
Chapter
His saying, "Say, He is the Able"
Numbering
Darussalam 7390
Bukhari 7390