Narrated ‘Abdullah bin ‘Amir from his father who said:
I saw the Prophet (p.b.u.h) offering the prayer on his mount (Rahila) whatever direction it took.
Related post here.
Narrated Jabir bin ‘Abdullah,
The Prophet used to offer the Nawafil, while riding, facing a direction other than that of the Qibla.
Ibn ‘Umar (while on a journey) used to offer the prayer and the Witr on his mount (Rahila). He said that the Prophet used to do so.
Narrated ‘Abdullah bin Dinar:
On traveling, ‘Abdullah bin ‘Umar used to offer the prayer on his Mount by signs whatever direction it took. ‘Abdullah said that the Prophet used to do so.
Narrated ‘Amir bin Rabi’a,
I saw the Prophet on his Mount praying Nawafil by nodding his head, whatever direction he faced, but Allah’s Apostle never did the same in offering the compulsory prayers. Narrated Salim: At night’Abdullah bin ‘Umar used to offer the prayer on the back of his animal during the journey and never cared about the direction he faced. Ibn ‘Umar said, “Allah’s Apostle used to offer the optional prayer on the back of his Mount facing any direction and also used to pray the Witr on it but never offered the compulsory prayer on it.”
Narrated Jabir bin ‘Abdullah
The Prophet used to pray (the Nawafil) on his Mount facing east and whenever he wanted to offer the compulsory prayer, he used to dismount and face the Qibla.
Narrated Anas bin Sirin:
We went to receive Anas bin Malik when he returned from Sham and met him at a place called ‘Ain-at-Tamr. I saw him praying riding the donkey, with his face to this direction, i.e. to the left of the Qibla. I said to him, “I have seen you offering the prayer in a direction other than that of the Qibla.” He replied, “If I had not seen Allah’s Apostle doing it, I would not have done it.”
Praying in cars, planes, trains or other means of conveyance, where one cannot face the qiblah or pray standing, is not permissible in the case of obligatory prayers unless two conditions are met:
1 – There should be the fear that the time for the obligatory prayer will end before reaching your destination. But if you will reach your destination before the time for prayer is over, you should wait until you get there to pray.
2 – It should not be possible to get off and pray on the ground. If it is possible to do so then you must do that.
If these two conditions are met, then it is permissible to pray in the vehicle. The evidence for it being permissible to pray in this case is the general meaning of the verses in which Allaah says (interpretation of the meaning):
“Allaah burdens not a person beyond his scope”
“So keep your duty to Allaah and fear Him as much as you can”
“and [Allaah] has not laid upon you in religion any hardship”
With regard to supererogatory (naafil) prayers, the matter is more relaxed; it is permissible for the Muslim to pray in the vehicles mentioned no matter what direction they are facing, even if he could get down on the ground at some times, because the Prophet (peace and blessings of Allaah be upon him) used to pray naafil prayers on his mount no matter what direction it was facing. Jaabir narrated that the Prophet (peace and blessings of Allaah be upon him) “used to pray voluntary prayers when he was riding without facing the qiblah.” (Narrated by al-Bukhaari, 1094). But it is better to face the qiblah when starting to pray a naafil prayer, if that is possible when travelling.
[Taken from IslamQA]