On the authority of Jabir Ibn Abdullah [May Allah be pleased with him], he said: ’The Prophet ﷺ would instruct us to pray for guidance in all of our concerns, just as he would teach us a chapter from the Quran. He ﷺ would say, ’ If any of you intends to undertake a matter, then let him pray two supererogatory units (two rak'ah nafilah) of prayer, and after which he should supplicate:
اللَّهُـمَّ إِنِّـي أَسْتَخِـيرُكَ بِعِلْـمِكَ، وَأَسْتَقْـدِرُكَ بِقُـدْرَتِكَ، وَأَسْأَلُـكَ مِنْ فَضْـلِكَ الْعَظِـيمِ، فَإِنَّـكَ تَقْـدِرُ وَلَا أَقْـدِرُ، وَتَعْـلَمُ وَلَا أَعْلَـمُ، وَأَنْتَ عَلَّامُ الْغُـيُوبِ، اللَّهُـمَّ إِنْ كُنْتَ تَعْـلَمُ أَنَّ هَذَا الْأَمْـرَ - يُسَـمِّي حَاجَتَهُ ,-, خَـيْرٌ لِي فِي دِينِـي وَمَعَـاشِي وَعَاقِـبَةِ أَمْـرِي - أَوْ قَالَ: عَاجِـلِهِ وَآجِـلِهِ - فَاقْـدُرْهُ لِي وَيَسِّـرْهُ لِي ثُمَّ بَارِكْ لِي فِـيهِ، وَإِنْ كُنْتَ تَعْـلَمُ أَنَّ هَذَا الْأَمْـرَ شَرٌّ لِي فِي دِينِـي وَمَعَـاشِي وَعَاقِـبَةِ أَمْـرِي - أَوْ قَالَ: عَاجِـلِهِ وَآجِـلِهِ - فَاصْـرِفْهُ عَنِّي وَاصْرِفْنِي عَنْهُ وَاقْـدُرْ لِيَ الْخَـيْرَ حَيْثُ كَانَ ثُمَّ أَرْضِـنِي بِهِ
Allāhumma innī astakhīruka bi‘ilmik, wa astaqdiruka biqudratik, wa as’aluka min faḍlika l-‘aẓīm, fa’innaka taqdiru wa lā aqdir, wa ta‘lamu wa lā a‘lam, wa anta ‘allāmu l-ghuyūb, allāhumma in kunta ta‘lamu anna hādha l-amr - yusammī ḥājatah - khayrun lī fī dīnī wa ma‘āšī wa ‘āqibati amrī - aw qāla: ‘ājilihi wa ājilih - fa-qdurhu lī wa yassirhu lī thumma bārik lī fīh, wa in kunta ta‘lamu anna hādha l-amr šarrun lī fī dīnī wa ma‘āšī wa ‘āqibati amrī - aw qāla: ‘ājilihi wa ājilih - fa-ṣrifhu ‘annī wa ṣrifnī ‘anhu wa qdur liya l-khayra ḥaythu kān, thumma arḍinī bih.
Translation
O Allah, I seek Your guidance by Your knowledge, and I seek Your decree by Your power, and I ask You from Your immense bounty. For You have power and I have none, You know and I know not, and You are the Knower of all that is hidden. O Allah, if You know that this matter - he names his need - is good for me in my religion, my livelihood, and the outcome of my affair - or he said: in the immediate and the eventual of it - then decree it for me, make it easy for me, and bless it for me. 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 the immediate and the eventual of it - then turn it away from me and turn me away from it, and decree for me what is good wherever it may be, then make me content with it.
When to recite
When seeking Allah's guidance in a decision, after praying two rak'ahs (istikharah).
Source / Reference
Hisnul Muslim 74
One who seeks guidance from his Creator and consults his fellow believers and then remains firm in his resolve does not regret, for Allah ﷻ has said:
﴾ وَشـاوِرْهُـم في الأمْـرِ فَـإِذا عَـزَمْـتَ فَتَوَكّـلْ عَلـى الله ﴿
..and consult them in the affair. Then when you have taken a decision, put your trust in Allaah... [Surah Ali 'Imran 3:159]