Praise be to Allah.
Forbidden prayer times
In the answers to questions no. 306 , 8818 , and 20013 , we have stated the times at which the Prophet (peace and blessings of Allah be upon him) forbade prayer. What is meant by this forbidding is general nafl prayers for which there is no reason.
As for nafl 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 istikharah prayer and whether it is regarded as a prayer for which there is a reason, or not.
The correct view is that if istikharah 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-Fatawa 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. Istikharah 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 wudu, even if that is at a time when prayer is not allowed. This is the view of al-Shafi’i.”
Can Istikharah be done at any time?
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) was asked: Can a person pray istikharah at a time when prayer is not allowed?
“If istikharah 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.” (Majmu’ Fatawa Ibn ‘Uthaymin, 14/275)
And Allah knows best.