1st Hadith - Deeds are by Intentions (Bukhari: 54)
عَنْ أَمِيْرِ الْمُؤْمِنِيْنَ أَبِيْ حَفْصٍ عُمَرَ بْنِ الْخَطَّابِ رَضِيَ اللهُ عَنْهُ قَالَ: سَمِعْتُ رَسُوْلَ اللهِ صلى الله عليه وسلم يَقُوْلُ: إِنَّمَا اْلأَعْمَالُ بِالنِّيَّاتِ وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى. فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللهِ وَرَسُوْلِهِ فَهِجْرَتُهُ إِلَى اللهِ وَرَسُوْلِهِ، وَمَنْ كَانَتْ هِجْرَتُهُ لِدُنْيَا يُصِيْبُهَا أَوْ امْرَأَةٍ يَنْكِحُهَا فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ.
1st Hadith Translation
It is narrated on the authority of Umar-Bin-Al-Khattab (R.A.), who said: I heard the Messenger of Allah (S.A.W.) say:
"Actions are (judged) by motives (intentions), so each man will have what he intended. Thus, he whose migration was to Allah and His Messenger, his migration is to Allah and His Messenger; but he whose migration was for some worldly thing he might gain, or for a wife he might marry, his migration is to that for which he migrated." (Bukhari: 54)
This hadith was said by the Prophet (S.A.W.) at the time when a man emigrated from Makkah to Madinah for the sake of marrying someone and not for the sake of Islam.
The Prophet (S.A.W.) starts the hadith with the principle ("Actions are judged by intentions") and then gives three examples. This is the methodology of the Prophet (S.A.W.). The examples help illustrate the principle so that it is easier for people to understand and they can apply the principle to other similar situations. The three examples consist of one of good intention (migration for the sake of Allah and His Messenger) and two of bad intentions (migration for the sake of worldly gains or for marriage).
Our actions are determined by our intentions - whether they are good intentions or bad intentions. Therefore we should always check our intentions before we do or say anything. We must make sure that the action is for the sake of Allah so that it is accepted by Allah and that we will be rewarded for it.
(Reference: Commentary of Forty Hadiths of An-Nawawi by Dr. Jamal Ahmed Badi)