Jabir bin Abdullah Al-Ansari (radhiAllahu anhu) reported: We accompanied the Prophet (sallaAllahu alayhe wasallam) in an expedition when he said, “There are some men in Al-Madinah who are with you wherever you march and whichever valley you cross. They have not joined you in person because of their illness.” In another version he said: “They share the reward with you.” [Muslim]
It is narrated by Bukhari from Anas bin Malik (radhiAllahu anhu): We were coming back from the battle of Tabuk with the Prophet (sallaAllahu alayhe wasallam) when he remarked, “There are people whom we left behind in Al-Madinah who accompanied us in spirit in every pass and valley we crossed. They remained behind for a valid excuse.”
Shaykh Ibn Uthaymeen says in his explanation of this hadith:
The meaning of this hadith is that if a person intends to do a good deed, but is then unable to complete it due to an obstacle in his way, the reward for what he intended would still be recorded for him.
So, if in the state of there being no excuse (to stop him from doing the deed) it was customary for one to perform the action, but he was then unable to do it, the reward for performing the whole deed would be recorded for him.
This is in accordance with the saying of the Prophet (sallaAllahu alayhe wasallam):
‘When a slave falls ill or travels, then he will get reward similar to that he gets for good deeds practiced at home when in good health.” (Bukhari).
Hence, the complete reward is written for the one who desires good and is keen on habitually performing a certain deed, but was faced with an obstacle.
For example: if it was customary for a person to attend the congregational prayer at the masjid, but then he was unable to do due to an obstacle such as sleep, illness or the like, then the reward for praying in the congregation is written for him completely without deficiency.
The same is applicable to the case of one who habitually performed the voluntary prayers, but was unable to do so; the complete reward (for the voluntary prayers) is written for him. Likewise is the case of one who customarily fasted three days of every month, but was prevented and was unable to do so; for him the reward is recorded completely. And the examples are many.
As for one who did not regularly perform a certain deed (but was not able to do it after intending to), only the reward of the intention is recorded for him, excluding the reward of the actual action.
Evidence for this: In the incident when the poor among the Companions (radhiAllahu anhum) said: “O Messenger of Allah, the rich have taken away all the rewards.” Meaning, that the wealthy have preceded them with sadaqah and freeing slaves. So the Prophet (sallaAllahu alayhe wasallam) said: “Shall I not teach you something whereby you will catch up with those who have preceded you and will get ahead of those who follow you, and no one will surpass you unless he does the same as you do?” Then he said: “Say: Subhan Allah, and Allahu Akbar, and praise Him (by saying Al-hamdu lillah) thirty-three times at the end of every Salat.” So they did that, and the wealthy knew of this and did the same. So the poor came to the Prophet (sallaAllahu alayhe wasallam) and said: “Our brothers, the possessors of wealth, having heard what we are doing, have started doing the same.” The Prophet (sallaAllahu alayhe wasallam) replied: “This is Grace of Allah which He gives to whom He wishes.” (Bukhari and Muslim) And Allah is the possessor of great bounty.
So the Prophet (sallaAllahu alayhe wasallam) did not tell them: you have gained the reward of their action. But there is no doubt that they earned the reward of the intention of the action.
For this reason also, the Prophet (sallaAllahu alayhe wasallam) mentioned the example of one whom Allah has granted wealth and he spends it in the way of Allah, while one who is poor says: ‘Had I possessed wealth, I would have acted like so-and-so.‘ The Prophet (sallaAllahu alayhe wasallam) said: “If that is his intention, his reward is the same as that of the other.” (Al-Tirmidhi). Meaning, the reward of the intention is the same. As for the action, he is not rewarded for it unless it was customary for him to do it.
In this hadith, there is also an indication that one who goes out for the sake of Allah, in jihad, is rewarded for his walking. This is why the Prophet (sallaAllahu alayhe wasallam) said (in the hadith above), “who are with you wherever you march and whichever valley you cross.”
There is evidence for this in the Words of Allah (subhanahu wata’ala):
وَلَا يُنفِقُونَ نَفَقَةً صَغِيرَةً وَلَا كَبِيرَةً وَلَا يَقْطَعُونَ وَادِيًا إِلَّا كُتِبَ لَهُمْ لِيَجْزِيَهُمُ اللَّهُ أَحْسَنَ مَا كَانُوا يَعْمَلُونَ
That is because they are not afflicted by thirst or fatigue or hunger in the cause of Allah, nor do they tread on any ground that enrages the disbelievers, nor do they inflict upon an enemy any infliction but that is registered for them as a righteous deed. Indeed, Allah does not allow to be lost the reward of the doers of good.
Nor do they spend an expenditure, small or large, or cross a valley but that it is registered for them that Allah may reward them for the best of what they were doing. (al–Tawbah 9:120,121).
Similar to this is the case of a man who makes wudhu in his house – performing it in the most perfect manner – then leaves for the masjid, going out for nothing except the salah. He does not take a step except that Allah raises him with it a degree and removes a sin.
It is from the grace and favor of Allah (azza wa jal), that the means to performing good deeds carry such rewards as the Prophet (sallaAllahu alayhe wasallam) described.
And Allah is the Granter of success.