Al-Ilmam bi-Ahadith al-Ahkam 348
وَعَن جَابر بن عبد الله رَضِيَ اللَّهُ عَنْهما، قَالَ: " كَانَ رَسُول الله ﷺ يعلمنَا الاستخارة فِي الْأُمُور كلهَا كَمَا يعلمنَا السُّورَة من الْقُرْآن، يَقُول: إِذا همَّ أحدكُم بِالْأَمر فليركع رَكْعَتَيْنِ من غير الْفَرِيضَة ثمَّ يَقُول: اللَّهُمَّ، إِنِّي أستخيرك بعلمك، وأستقدرك بقدرتك، وَأَسْأَلك من فضلك الْعَظِيم، فَإنَّك تقدر وَلَا أقدر وَتعلم وَلَا أعلم، وَأَنت علام الغيوب. اللَّهُمَّ، إِن كنت تعلم أَن هَذَا الْأَمِير خير لي فِي ديني ومعاشي وعاقبة أَمر، أَو قَالَ: فِي عَاجل أَمْرِي وآجله فاقدره لي ويسره لي، ثمَّ بَارك لي فِيهِ، وَإِن كنت تعلم أَن هَذَا الْأَمر شَرّ لي فِي ديني ومعاشي وعاقبة أَمْرِي، أَو قَالَ: فِي عَاجل أَمْرِي وآجله، فاصرفه عني واصرفني عَنهُ، واقدر لي الْخَيْر حَيْثُ كَانَ، ثمَّ أرضني بِهِ. قَالَ: ويسم حَاجته ". انْفَرد بِهِ البُخَارِيّ. فصل
And from Jabir ibn ʿAbdullah, may Allah be pleased with them both, who said: "The Messenger of Allah ﷺ used to teach us istikharah in all matters as he taught us a surah of the Quran. He would say: 'When one of you is concerned about a matter, let him pray two rakʿahs other than the obligatory prayer, then say: O Allah, I ask You to choose for me by Your knowledge, and I ask You to enable me by Your power, and I ask You of Your great bounty, for You are able and I am not able, and You know and I do not know, and You are the Knower of the unseen. O Allah, if You know that this matter is good for me in my religion, my livelihood and the outcome of my affair — or he said: in my affairs now and later — then decree it for me, make it easy for me, then bless me in it. And if You know that this matter is bad for me in my religion, my livelihood and the outcome of my affair — or he said: in my affairs now and later — then turn it away from me and turn me away from it, and decree for me the good wherever it may be, then make me content with it.' He said: 'And let him name his need.'" Al-Bukhari alone narrated it. Section.