Firstly, we have already stated in the answer to question no. 20165 that fasting whilst travelling may fall into three categories:
1 – If fasting does not cause hardship, then it is preferable to fast.
2 – If fasting causes hardship, then it is better to break one's fast.
3 – If a person will be harmed by fasting or there is the fear that he may die, then fasting becomes haraam and he has to break his fast.
We have also quoted evidence from the Sunnah concerning that.
Secondly: This hadeeth to which the questioner refers applies in the third case. If we know the context of the hadeeth and the reason why it was narrated, that will become clear.
Al-Bukhaari (1946) and Muslim (1115) narrated from Jaabir ibn ‘Abd-Allaah (may Allaah be pleased with him) that the Messenger of Allaah (peace and blessings of Allaah be upon him) was on a journey, and he saw a crowd of people and a man who was being shaded. He said, “What is this?” They said, “He is fasting.” He said, “It is not an act of righteousness to fast whilst travelling.”
The words “It is not an act of righteousness …” mean it is not an act of obedience or worship.
What it means is that if it is too difficult for you to fast and you fear that it may harm you. The context of the hadeeth indicates that this is how it should be interpreted… The hadeeth has to do with one who may be harmed by fasting.
This is the way in which al-Bukhaari understood the hadeeth. He introduced it by saying:
“Chapter: The words of the Prophet (peace and blessings of Allaah be upon him) to one who was being shaded when the heat was too intense, ‘It is not an act of righteousness to fast when travelling.’”
By this introduction he indicated that the reason why the Prophet (peace and blessings of Allaah be upon him) said “It is not an act of righteousness to fast when travelling” is the hardship that was mentioned.
Ibn al-Qayyim said in Tahdheeb al-Sunan:
With regard to the words “It is not an act of righteousness to fast when travelling”, this was said concerning a specific person whom the Messenger of Allaah (peace and blessings of Allaah be upon him) saw being shaded and fasting had exhausted him. So he said these words, i.e., it is not an act of righteousness for a person to exhaust himself to this extent when Allaah has allowed him not to fast.
This hadeeth cannot be interpreted in general terms to mean that it is not an act of righteousness to fast on any type of journey, because it is proven that the Prophet (peace and blessings of Allaah be upon him) used to fast when travelling.
Hence al-Khattaabi (may Allaah have mercy on him) said:
These words were spoken for a reason, so they are limited to those who are in a similar situation. It is as if he said that it is not an act of righteousness for a traveller to fast if fasting will lead to him suffering in such a manner. And the Prophet (peace and blessings of Allaah be upon him) fasted on his journey in the year of the Conquest.
From ‘Awn al-Ma’bood.
And Allaah knows best.