The qibla direction: what to do when on a train
Question
If a person praying on a train or on some other kind of conveyance began the prayer (made the niyya) facing exactly towards the qibla, and then, when the conveyance changed direction, he too corrected his direction; or he did not notice during the prayer that the conveyance had turned and did not straighten his direction — is it obligatory for him, after getting off the conveyance, to repeat (i'ada) that prayer or all such prayers?
Answer
In the case asked about, if when the train changed direction he also corrected his own direction (towards the qibla), then the prayer is valid and there is no need to repeat it. But if, despite being able to, he did not turn towards the correct qibla direction, then the prayer is not valid.
Source: Fatawa Mahmudiyya
Preview. The full text opens with JavaScript enabled.