FACING THE KA'BAH (Istiqbaalul-Ka'bah)
(1) If you stand, O Muslim, to pray - then face the direction of the Ka'bah, wherever you are, in obligatory Prayers and optional Prayers. This is one of the pillars of the Prayer, such that the Prayer is not valid without it.
(2) The obligation to face the direction of the Ka'bah is removed from a warrior having to pray the Fear Prayer and during severe fighting. It is also removed from one who is rendered incapable of it, such as one who is (very) ill, or one who is upon a ship, car or airplane and who fears that the Prayer time will reach its end. It is also removed from one who prays optional Prayer or the Witr Prayer upon a riding beast or vehicle. It is, however, preferable for him, if he is able, to turn it towards the Qiblah for the initial takbeer. After that it does not matter in which direction it turns.
(3) It is obligatory upon everyone who can actually see the Ka'bah to face it directly. As for those who cannot actually see it then they should face its direction.
THE RULING CONCERNING PRAYING TOWARDS A DIRECTION OTHER THAN THAT OF THE KA'BAH BY MISTAKE
(4) If a person prays towards other than the Qiblah due to the sky being cloudy or for any reason other than that, after having tried to the best of his knowledge and ability to face the correct direction, then his Prayer will be correct and he will not have to repeat it.
(5) However if a person whom he holds to be reliable comes to him whilst he is praying and informs him of the correct direction, then he must immediately turn to the correct direction, and his Prayer will be correct.
These episodes are selected from the book: The Abridgement of The Prophet's Prayer described by Sheikh Muhammad Naasirud-deen al-Albaanee.