It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) used to teach us istikharah (seeking what is best) in any matter just as he would teach one of us a surah of the Qur'an: 'Allahumma inni astakhiruka bi-'ilmika, wa astaqdiruka bi-qudratika, wa as'aluka min fadlika, fa-innaka taqdiru wa la aqdiru, wa ta'lamu wa la a'lamu, wa anta 'allamul-ghuyub, Allahumma in kana fi hadhal-amri khiratun fi dini wa dunyaya wa 'aqibati amri fa-qaddirhu li, wa in kana ghayru dhalika khayran li fa-sahhil liyal-khayra haythu kana, wasrif 'annis-su'a, wa raddini bi-qada'ika' (O Allah, I seek what is best from You by Your knowledge, I seek ability from You by Your power, and I ask You of Your bounty, for You have power and I have none, You know and I do not know, and You are the Knower of the unseen. O Allah, if there is good in this matter for my religion, my worldly life and the outcome of my affairs, then decree it for me; and if something other than it is better for me, then make the good easy for me wherever it may be, turn evil away from me, and make me content with Your decree.)
Imam al-Tabarani (may Allah have mercy on him) said: "No one narrated this hadith from Imam Abu Hanifah (may Allah have mercy on him) except Isma'il bin Ayyash (may Allah have mercy on him)."
Hadith Referenceالمعجم الأوسط / باب العين / 3723
Hadith Takhrij«أخرجه البزار فى «مسنده» برقم: 1528، 1583، 1835، 1834، وعبد الرزاق فى «مصنفه» برقم: 20210، وابن أبي شيبة فى «مصنفه» برقم: 30015، والطبراني فى «الكبير» برقم: 10012، 10052، 10421، والطبراني فى «الصغير» برقم: 524، والطبراني فى «الأوسط» برقم: 3724، 7332»