Prophet Muhammad disclosed that God rewards according to the intention of each individual. The non-believer expects to be rewarded for his deeds in the present life because he denies or doubts the existence of another life after his death. Thus, he is keen that people should recognize what he does; when he is praised and his deed publicized, he is pleased, for this is the reward he sought. He might also obtain a sum of money in payment for it or a prize. This is the compensation he likes most, and God grants it to him. But he is not given additional reward in the Hereafter simply because he neither desired it nor worked for it.
The believer, on the other hand, is not duly concerned with compensation in this life because he is striving for the greater eternal reward of the Hereafter. He does so by worshiping God as He stipulated and by working patiently, honestly and correctly to the best of his ability, even when no person appreciates his efforts. Because his deeds are done seeking God's acceptance, they are appreciated by Him and rewarded.
Islam teaches that there are two conditions for God's approval and reward of any deed:
That it is done explicitly for His acceptance and approval and
That it is consistent with the methods ordained by Him. In other words, a person must work for God according to the terms He has specified and not according to his own preferences or those of other people. In order to know exactly what God expects of His servants, it is necessary to refer to the legislation revealed by Him in its final form through Muhammad, the final prophet.