It wasnarrated that Jabir bin 'Abdullah said:
"The Messenger ofAllah(ﷺ) used to teach us Istikharah, just as he used to teach us aSurah of the Qur'an. He said: 'If anyone of you is deliberatingabouta decision he has to make, then let him pray two Rak'ah ofnon-obligatory prayer, then say: Allahumma inni astakhiruka bi'ilmika waastaqdiruka bi qudratika wa as'aluka minfadlikal-'azim, fa innakataqdiru wa la aqdir, wa ta'lamu wa laa'lam, wa Anta 'allamul-ghuyub.Allahumma in kunta ta'lamuhadhal-amra (then the matter should bementioned by name) ma kan minshay'in khairan li fi dini wa ma'ashi wa'aqibati amri, awkhairanli fi 'ajili amri wa ajilihi, faqdurhu li wayassirhu li wabarik li fihi. Wa in kunta ta'lamu [O Allah, I seekYour guidance(in making a choice) by virtue of Your knowledge, and Iseek abilityby virtue of Your power, and I ask You of Your greatbounty. You havepower, I have none. And You know, I know not. You arethe Knower ofhidden things. O Allah, if in Your knowledge, thismatter (then itshould be mentioned by name) is good for me in myreligion, mylivelihood and my affairs, or both in this world and inthe Hereafterthen ordain it for me, make it easy for me, and bless itfor me. Andif in Your knowledge]. Then saying similar to what he saidthe firsttime, except: Wa in kana sharran li fasrifhu 'anni wasrifni'anhuwaqdur li al-khair haithuma kana thumma raddini bihi (If it isbadfor me then turn it away from me and turn me away from it, andordainfor me the good wherever it may be and make me pleased withit).'"
English reference: Vol. 1, Book 5, Hadith 1383
Arabic reference: Book 5, Hadith 1446