Narrated Jâbir bin Abdullâh
The Prophet (ﷺ) used to teach us the way of doing Istikhâra in all matters as he taught us the Sûrah of the Qur'ân (Istikhâra means to ask Allâh to guide one to the right sort of action concerning any job or a deed). He said, "If anyone of you decides to do any job he should offer a two Rak'at (prayer) other than the compulsory ones and say [after the (prayer)]:-
'Allâhumma inní astakhîruka bi-ilmika, wa astaqdiruka bi-qudratika, wa as’aluka min faḍlika- al-' Azim Fa-innaka taqdiru walâ aqdiru, wa ta‘lamu walâ a'lamu, wa Anta ' Allâmul-ghuyûb. Allâhumma, in kunta ta'lamu anna hadhal-amra khairun li fi dîni wa ma'âshî wa âqibati amrî ' (or âjili amri wa âjilihi) faqdurhu-li wa yas-sirhu li, thumma bârik li fîhi, wa in kunta ta‘lamu anna hadhal-amra shar-run li fi dini wa ma'âshî wa‘aqibati amrṛ ' or ' fi'âjili amri wa ajilihi, fașrifhu annî was-rifnî ' anhu, waqdur li al-khaira ḥaithu kâna thumma ardini bihi.
(O Allah, I consult You as You are All-Knowing, and appeal to You to give me power as You are Omnipotent, and ask You for Your Great Favour, for You have power, but I don't, and You have knowledge, but I don't have, and You know all hidden matters. O Allâh, if You know that this matter is good for me in my religion, my livelihood, and for my life in the Hereafter (or said: For my present, and future life), then do it for me; and if You know that this matter is evil (not good) for me in my religion, my livelihood, and for my life in the Hereafter (or said: For my present and future life), then keep it away from me and take me away from it, and choose what is good for me wherever it is, and please me with it.) "
The Prophet (ﷺ) added that then the person should name (mention) his need (matter etc.). [2:263-O.B.]