Like the resident, a traveller should face the direction of the Ka`bah when praying. If circumstances beyond our control prevent this, however — as is the case while traveling in planes sometimes —then we must still perform our prayer by facing whichever direction we possibly can; in this case also, if possible, first we should make the opening takbeer facing the qiblah (direction of the prayer) — if it can be ascertained — and then sit down and pray facing whichever direction the plane travels.
Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: Facing the direction of qiblah is a condition for the validity of prayer. It has been clearly established by the clear imperative of Allah in the Qur’an, “So from wherever you depart, turn your face towards the Sacred Mosque.” (Al-Baqarah: 148) “And wherever you are (O Muslims) face towards it (when you pray)…” (Al-Baqarah: 149)
It is, therefore, unanimously agreed upon by scholars that one must face towards the Ka`bah while performing prayer, and as such, we are required to ascertain the direction to the best of our ability. But, if for some reason, we are unable to determine the precise direction, then we must act upon our best educated guess and pray accordingly. If, however, we are unable to face the direction of Ka`bah because of circumstances beyond our control — as is the case while traveling in planes sometimes —, then we must still perform our prayer by facing whichever direction we possibly can; in this case also, if possible, first make your opening takbeer facing the qiblah — if it can be ascertained — and then sit down and pray facing whichever direction the plane travels. We are not allowed to skip our prayer on the excuse we cannot face the qiblah.
According to an established principle of Islamic jurisprudence if for any reason we are unable to fulfill a certain condition or pre-requisite (shart) on which the validity of a certain act of worship is dependent, then we must still perform the act without the condition. Allah tells us in the Qur’an, “So fear Allah as best as you can, and listen and obey…” (At-Taghabun: 16). Also, the Prophet (peace and blessings be upon him) said, “If I order you to do something, do it as best as you can.”