Allah, Mighty and Majestic:
โTurn your face toward the Sacred Mosque, and wherever you are, turn your faces toward it.โ [al-Baqarah: 144]
Those who can see the qiblah must face it, while those who cannot must exercise their best judgment to determine its direction from the signs indicating it. If someone prays without exercising his judgment, his prayer is invalid, even if he happens to face the qiblah. If he exercises his judgment but subsequently discovers that he was mistaken and prayed with his back to the qiblah, or facing east or west, it is recommended that he repeat the prayer within its prescribed time. Al-Shฤfiสฟฤซ said that if he prayed with his back to the qiblah, he must repeat the prayer, whether within its prescribed time or afterwards. This is also the view of al-Mughฤซrah, one of our scholars.
Our evidence is the report from สฟฤmir ibn Rabฤซสฟah, who said: โWe were travelling with the Messenger of Allah, peace and blessings be upon him, on a dark night, and we could not determine the direction of the qiblah. Each of us prayed facing his own direction, and we made marks. When morning came, we discovered that we had prayed in a direction other than the qiblah. We asked the Messenger of Allah, peace and blessings be upon him, about this, and he said: โYour prayer is valid.โ Then the following was revealed: โWherever you turn, there is the Face of Allah.โ [al-Baqarah: 115]โ
When someone who exercises his judgment in determining the qiblah makes a mistake, he does not then arrive at certainty; rather, he resorts to another judgment of the same kind. He is therefore not required to repeat the prayer except within its prescribed time. This differs from someone who prays in a direction other than the qiblah while in a place where he can see it: if he makes a mistake, he can turn to certainty rather than to a judgment.
Section
As for bowing and prostrating, the evidence that they are obligatory is the statement of Allah, Mighty and Majestic:
โO you who believe, bow and prostrate.โ [al-Hajj: 77]
And His statement, Exalted is He:
โO Mary, be devoutly obedient to your Lord, prostrate, and bow with those who bow.โ [ฤl สฟImrฤn: 43]
And His statement, Mighty and Majestic:
โAnd those who bow and prostrate.โ [al-Baqarah: 125]
And His statement, Exalted is He:
โThose who bow and prostrate.โ [al-Tawbah: 112]