“To Allah belong the East and the West. So wherever you turn, there is the Face of Allah. Indeed, Allah is All-Encompassing, All-Knowing.”
(Qur’an, Surah Al-Baqarah 2:115)
It was narrated by At-Tirmidhi from ʿĀmir ibn Rabīʿah, from his father, who said:
“We were with the Prophet ﷺ on a journey during a very dark night. We could not determine the direction of the Qiblah. So each man prayed toward the direction he thought was correct.
When morning came, we mentioned this to the Prophet ﷺ, and then Allah revealed:
‘So wherever you turn, there is the Face of Allah.’”
This narration clearly indicates the reason for the revelation of this verse.
In another version, ʿĀmir said:
“We were traveling with the Messenger of Allah ﷺ when the sky became overcast, and we were uncertain about the direction of the Qiblah. We prayed according to our best judgment, and when the sun rose, we realized that we had prayed in the wrong direction.
We told the Prophet ﷺ about it, and Allah then revealed:
‘So wherever you turn, there is the Face of Allah.’”
From this verse, scholars deduced that if a person is required to perform prayer but cannot determine the Qiblah direction, and yet makes a sincere effort (ijtihād) to find it — such as asking other Muslims or reasoning by observation — and then prays, his prayer is valid.
His duty before Allah is fulfilled.
If he later discovers that he prayed facing the wrong direction and repeats the prayer, then this is considered an innovation (bid‘ah) — because the first prayer was already accepted.