عن عمر بن الخطاب رضي الله عنه قال: قال رسول الله صلى الله عليه وسلم:
«إِنَّمَا الْأَعْمَالُ بِالنِّيَّةِ، وَإِنَّمَا لِامْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللهِ وَرَسُولِهِ، فَهِجْرَتُهُ إِلَى اللهِ وَرَسُولِهِ، وَمَنْ كَانَتْ هِجْرَتُهُ لِدُنْيَا يُصِيبُهَا أَوِ امْرَأَةٍ يَتَزَوَّجُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ».
وفي لفظ للبخاري: «إِنَّمَا الْأَعْمَالُ بِالنِّيَّاتِ، وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى».
[صحيح] - [متفق عليه] - [صحيح مسلم: 1907]
المزيــد ...
‘Umar ibn al-Khattāb (may Allah be pleased with him) reported: The Messenger of Allah (may Allah’s peace and blessings be upon him) said:
"Verily, the reward of deeds depends on the intention, and a person will be rewarded according to what he intended. So, he whose migration is for the sake of Allah and His Messenger, then his migration is for the sake of Allah and His Messenger, and he whose migration is to achieve some worldly gain or take some woman in marriage, then his migration is for what he migrated for." In a version by Al-Bukhāri: "Verily, the reward of deeds depends on the intentions, and each person will be rewarded according to what he intended."
[Authentic hadith] - [Narrated by Bukhari & Muslim] - [Sahih Muslim - 1907]
The Prophet (may Allah's peace and blessings be upon him) explains that all deeds are considered according to the intention behind them. This ruling generally applies to all deeds, including acts of worship and dealings. So, he who seeks by his deed some worldly benefit will attain that benefit and will not be rewarded for it. And he who performs a deed with the intention to draw close to Allah Almighty will be rewarded, even if his deed is an ordinary one, like eating and drinking.
Then, the Prophet (may Allah's peace and blessings be upon him) provided an example to illustrate the impact of intention while both deeds apparently look equal. He pointed out that if a person migrates and leaves his homeland with the intention to win the pleasure of his Lord, his migration is a Shar‘i and accepted one, for which he will be rewarded, given his sincere intention; and if a person migrates to attain some worldly benefit, like wealth, high standing, business, or a wife, he will not attain anything from his migration except what benefit he intended, and no reward will be given to him.