The Messenger of Allah ﷺ used to teach us the prayer of seeking guidance (istikharah) just as he taught us a surah from the Quran. He would say, "When one of you is concerned about a matter, let him pray two rakahs other than the obligatory prayer, then let him say,'O Allah, I seek Your guidance through Your knowledge, and I seek ability through Your power, and I ask You from Your immense bounty. For You are able and I am not, and 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, 'is good for me in my religion and my livelihood'" — Abu Saeed said, "and my life and the outcome of my affair, then decree it for me and make it easy for me, then bless me in it.O Allah, and if You know it to be bad for me in my religion, my livelihood, and the outcome of my affair, then turn me away from it and turn it away from me, and decree good for me wherever it may be, then make me content with it."Abu Saeed said, "and the outcome of my affair, then decree it for me, make it easy for me, and bless me in it. O Allah, and if You know it to be bad for me in my religion, my livelihood, and the outcome of my affair, then turn me away from it and turn it away from me, and decree good for me wherever it may be, then make me content with it."Abu Abdul-Rahman said, Mansur bin Abu Muzahim narrated it to us, Abdul-Rahman bin Abu al-Mawal narrated to us, from Muhammad bin Munkadir, from Jabir, from the Prophet ﷺ, something similar.
حدثنا إسحاق بن عيسى وأبو سعيد يعني مولى بني هاشم المعنى وهذا لفظ إسحاق قالا حدثنا عبد الرحمن بن أبي الموال المدني حدثنا محمد بن المنكدر
كان رسول الله ﷺ يعلمنا الاستخارة كما يعلمنا السورة من القرآن يقول إذا هم أحدكم بالأمر فليركع ركعتين من غير الفريضة ثم ليقل اللهم إني أستخيرك بعلمك وأستقدرك بقدرتك وأسألك من فضلك العظيم فإنك تقدر ولا أقدر وتعلم ولا أعلم وأنت علام الغيوب اللهم فإن كنت تعلم هذا الأمر يسميه باسمه خيرا لي في ديني ومعاشي قال أبو سعيد ومعيشتي وعاقبة أمري فاقدره لي ويسره ثم بارك لي فيه اللهم وإن كنت تعلمه شرا لي في ديني ومعاشي وعاقبة أمري فاصرفني عنه واصرفه عني واقدر لي الخير حيث كان ثم رضني به وقال أبو سعيد وعاقبة أمري فاقدره لي ويسر لي وبارك لي فيه اللهم وإن كنت تعلمه شرا لي في ديني ومعاشي وعاقبة أمري فاصرفني عنه واصرفه عني واقدر لي الخير حيث كان ثم رضني به قال أبو عبد الرحمن حدثناه منصور بن أبي مزاحم حدثنا عبد الرحمن بن أبي الموال عن محمد بن المنكدر عن جابر عن النبي ﷺ نحوه
Its chain of transmission is sahih. Bukhari narrated it in 2/70, in the chapter on shortening the prayer, on what has been said about voluntary prayers two by two. Abu Dawud narrated it in 2/89, in the book of prayer, chapter on istikhara. Tirmidhi narrated it in 2/345, no. 480, in the chapter on voluntary prayers, on what has been said about the prayer of istikhara, and he said, hasan sahih gharib. Nasai narrated it in 6/80, no. 3252, in the book of marriage, chapter on how istikhara is performed. Ibn Majah narrated it in 1/440, no. 1383, in the chapter on establishing the prayer, on what has been said about the prayer of istikhara.14642m - Abu Abdul-Rahman said, Mansur bin Abu Mizahim narrated to us, Abdul-Rahman bin Abu Mawwal narrated to us, from Muhammad bin Munkadir, from Jabir, from the Prophet ﷺ, similarly. Sahih (14642m). Its chain of transmission is sahih, and it is among the additions.