Praise be to Allah.
In the answer to questions no. 306, 8818, and 20013, we have stated the times at which the Prophet (peace and blessings of Allaah be upon him) forbade prayer. What is meant by this forbidding is general naafil prayers for which there is no reason. As for naafil prayers for which there is a reason, such as greeting the mosque, they may be offered at these times when prayer is not allowed.
The scholars differed concerning istikhaarah prayer and whether it is regarded as a prayer for which there is a reason, or not.
The correct view is that if istikhaarah is done for something that is immediate and cannot be delayed, then this prayer may be performed at a time when prayer is not allowed, such as if a person wants to travel after ‘Asr prayer. But if the matter is not immediate and the prayer can be delayed until after the time when prayer is not allowed is over, then it should not be performed at that time.
Shaykh al-Islam Ibn Taymiyah said in al-Fataawa al-Kubra (5/345):
Regular Sunnah prayers may be made up, and prayers for which there is a reason may be done during the times when prayer is not allowed. This is one of the two views narrated from Ahmad, and is the view favoured by a number of our companions and others. Istikhaarah prayer may be performed at the time when prayer is not allowed with regard to something that is immediate and cannot be delayed until the time when prayer is permitted.
It is mustahabb to offer two rak’ahs immediately after doing wudoo’, even if that is at a time when prayer is not allowed. This is the view of al-Shaafa’i. End quote.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was asked: Can a person pray istikhaarah at a time when prayer is not allowed?
If istikhaarah has to do with an immediate matter that cannot be delayed until the time when prayer is not allowed is over, then it may be done. If it is for something that may be delayed, then it must be delayed. End quote.
Majmoo’ Fataawa Ibn ‘Uthaymeen, 14/275.