allah, the exalted, says:
"and consult them in the affairs.'' (3:159)
"and who (conduct) their affairs by mutual consultation.'' (42:38)
718. jabir (may allah be pleased with him) reported: messenger of allah (pbuh) used to teach us the istikharah (seeking guidance from allah) in all matters as he would teach us a surah of the qur'an. he used to say: "when one of you contemplates entering upon an enterprise, let him perform two rak`ah of optional prayer other than fard prayers and then supplicate: "allahumma inni astakhiruka bi `ilmika, wa astaqdiruka bi qudratika, wa as-'aluka min fadlikal-`azim. fainnaka taqdiru wa la aqdiru, wa ta`lamu wa la a`lamu, wa anta `allamul-ghuyub. allahumma in kunta ta`lamu anna hadhal-`amra (and name what you want to do) khairun li fi dini wa ma`ashi wa `aqibati amri, (or he said) `ajili amri ajilihi, faqdurhu li wa yassirhu li, thumma barik li fihi. wa in kunta ta`lamu anna hadhal `amra (and name what you want to do) sharrun li fi dini wa ma`ashi wa `aqibati amri, (or he said) wa `ajili amri wa ajilihi, fasrifhu `anni, wasrifni `anhu, waqdur liyal-khaira haithu kana, thumma ardini bihi.'' (o allah, i consult you through your knowledge, and i seek strength through your power, and ask of your great bounty; for you are capable whereas i am not and, you know and i do not, and you are the knower of hidden things. o allah, if you know that this matter (and name it) is good for me in respect of my deen, my livelihood and the consequences of my affairs, (or he said), the sooner or the later of my affairs then ordain it for me, make it easy for me, and bless it for me. but if you know this matter (and name it) to be bad for my deen, my livelihood or the consequences of my affairs, (or he said) the sooner or the later of my affairs then turn it away from me, and turn me away from it, and grant me power to do good whatever it may be, and cause me to be contented with it). and let the supplicant specify the object.''
[al-bukhari and muslim]
commentary: literally istikharah means seeking goodness from allah through a particular prayer. this hadith lays emphasis on it and displays its significance. we should, therefore, practise istikharah regarding every important matter. however, it is imperative only in cases where one is ignorant of good and evil. yet, with regard to obligatory and indisputable rules, practices of the prophet (pbuh) and commendable deeds, no istikharah is allowed. similarly, commands and prohibitions of the shari`ah are categorical and nobody is allowed to seek further guidance by performing istikharah prayer. moreover, to set aside the example of the prophet (pbuh) of istikharah, and to trust astrologers, palmists and soothsayers seeking the knowledge of future events is sheer ignorance and unpardonable error. the knowledge of the unseen (or ghaib) is the domain of allah alone and man is supposed to seek his blessings. only allah is omnipotent and humans must turn to him to seek inspiration and strength, trusting everything to his care.
istikharah prayer can be offered at any time except in the forbidden hours for prayer because the performance of two rak`ah is a prerequisite to it. some people think that the right time for it is before going to bed. this is not true. this supplication (du`a) can be offered even after performing the two rak`ah of istikharah prayer, or before taslim (i.e., saying assalamu `alaikum to conclude the prayer) after tashahhud or in the state of prostration. if somebody does not know this du`a by heart, he can, after performing the prayer, read it from some prayerbook.