"Put your trust in Allah, certainly, Allah loves those who put their trust (in Him)."[Surah al-Imran; 3:159]
Whenever a person is faced with a difficult problem, or becomes hesitant in making a decision and his knowledge of the matter is insufficient to guide him then after seeking advice from trusted friends and family, he should turn to Allah and beseech His grace. He should willingly and with an open heart and mind supplicate for divine guidance and ask for direction so that the problem is solved in his own best interest. The Du'a at such an occasion is called Istikharah.
Anytime a Muslim is making a decision, he or she should seek Allah's guidance and wisdom. Allah alone knows what is best for us, and there may be good in what we perceive as bad, and bad in what we perceive as good. This prayer is usually made when making a decision to marry someone, or working out which university to attend, and so on. But it can be related to any significant, or insignificant aspect of a person's life. If confused about a decision, where you have a choice to make, make this prayer. Simply, seek Allah (Ta'ala)'s guidance.
It comprises of a two rakat non-obligatory (nafil) prayer, prayed at anytime during the day, with the specified du'a recited at the end.
The Dua for salat al-Istikharah
According to a traditional report transmitted on the authority of Muhammad ibn al-Munkadir, it was Jabir ibn 'Abdillah (radiAllahu anhum) who said:
"Allah's Messenger (salAllahu alayhi wasalam) used to teach us how to seek guidance in choosing the best option available in a practical enterprise [al-istikhara fi'l-amr], just as he would sometimes teach us a Chapter (Surah) from the Qur'an.:
"'If one of you is concerned about some practical undertaking, or about making plans for a journey, he should perform two cycles of ritual prayer [rak'atain], not as an obligatory observance [farida], but voluntarily. Then he should say:
الَّلهُمَّ إنِّي أسْتَخْيرُكَ بِعِلْمِكَ وَ أسْتَقْدِرُكَ بِقُدْرَتِكَ، وَ أسْألُكَ مِنْ فضْلِكَ الْعَظيِمِ، فَإنَّكَ تَقْدِرُ وَلا أقْدِرُ، وَتَعْلَمُ وَلا أعْلَمُ، وَأنْتَ عَلَّامُ الْغُيُوبِ. الَّهُمَّ إنْ كُنْتَ تَعْلمُ أنَّ [هذَا الْأمْرَ] خَيْرٌ لي فِي دِينيِ وُ مَعَاشِي وَ عَاقِبَةِ أمْرِي أوْ قَالَ عَجِل أمْرِى وَآجِلِهِ فاقْدُرْهُ لى وَيَسِّرْهُ لِى ثُمَّ بَارِكْ لى فِيهِ؛ وَإنْ كُنْتَ تَعْلمُ أنَّ [هذَا الأمْرَ] شَرٌّ لى فى دِينِى وَمَعَاشِى وِعَاقِبَةِ أمْرِى، أوْ قَاَلَ فِى عَاجِلِ اْمْرى وَآجِلِهِ، فَاصرِفْنىِ عَنْهُ، وَقْدُرْ لِى الْخيْرَ حَيْثُ كانَ ثُمّ ارْضِنِى بِهِ.
Allahumma inni astakhiruka bi ilmika wa-astaqdiruka biqudratika wa-as'aluka min fadhlika al-adheem. Fa innaka taqdiru wala' aqdiru. Wa ta'lamu wala a'alamu wa anta allaamul ghuyub. Allahumma in kunta ta'lamu anna [hadhal-amr] khayrun li fi deeni wa-ma'ashi wa-aqibat amri, fa'qdruhli wa-yasirh li thumma barik li feehi. Wa in-kunta ta'lamu anna [hadhal amr] sharrun li fi deeniy wa-ma'ashi was-'aqibat amri. Fa asrifh anni wa-srif 'anhu. Wa aqdurh liyal khayr hayth kana thumma a-rdhini bihi
O Allah! I seek Your counsel by Your knowledge and by Your power I seek strength and I ask You from Your immense favour, for verily You are able while I am not and verily You know while I do not and You are the Knower of the unseen. O Allah! If You know this affair [this matter] to be good for me in relation to my religion, my life, and end, then decree and facilitate it for me, and bless me with it. But if in Your Knowledge, You know [this matter] to be ill for me towards my religion, my life, and end, then drive it away from me and drive me away from it, and decree for me what is good wherever it be and make me satisfied with such.
Imam an-Nawawi holds that "after performing the istikharah, a person must do what he is wholeheartedly inclined to do and feels good about doing and should not insist on doing what he had desired to do before making the istikharah. And if his feelings change, he should leave what he had intended to do, otherwise he is not completely leaving the choice to Allah, and would not be honest in seeking aid from Allah's power and knowledge. Sincerity in seeking Allah's choice, means that one should completely leave what he himself had desired or determined."
Summary of the method
In time of decision making, and a feeling of uncertainty about your affairs.
You wish to pray to Allah Ta'ala to seek some guidance (on a halal matter).
Before reciting the dua' make sure that you are not already inclined to a given decision; otherwise it will mean that you are not serious about seeking guidance from Allah (Ta'ala).
You perform the prayer, and recite the cited dua' at the end.
Upon performing the prayer, you will have a feeling or inclination towards one choice. So that is the choice that you have to take, inshaAllah (God Wiling).
If your his mind has not been made up after the first day, and some doubt still persists, then repeat the salah the following day. This can be continued for up to seven days. InshaAllah, you will come to know of the advantage or disadvantage of that matter.
After performing the salah, one should "have a good feeling" -- a 'firmness' about one of the options. Whatever option one feels is best right after saying the du'a should be the decision. If still in doubt, the salat can be repeat (up to seven times). After having placed one's trust in Allah (Subhanahu wa Ta'ala), simply following one's feelings after performing it.
*Source: Quran & Hadith