Sahih al-Bukhari, Hadith 6953 ⓘ
Narrated `Umar bin Al-Khattab: The Prophet said, 'O people! The reward of deeds depends upon the intentions, and every person will get the reward according to what he has intended. So, whoever emigrated for Allah and His Apostle, then his emigration was for Allah and His Apostle, and whoever emigrated to take worldly benefit or for a woman to marry, then his emigration was for what he emigrated for."
حَدَّثَنَا أَبُو النُّعْمَانِ، حَدَّثَنَا حَمَّادُ بْنُ زَيْدٍ، عَنْ يَحْيَى بْنِ سَعِيدٍ، عَنْ مُحَمَّدِ بْنِ إِبْرَاهِيمَ، عَنْ عَلْقَمَةَ بْنِ وَقَّاصٍ، قَالَ سَمِعْتُ عُمَرَ بْنَ الْخَطَّابِ ـ رضى الله عنه ـ يَخْطُبُ قَالَ سَمِعْتُ النَّبِيَّ صلى الله عليه وسلم يَقُولُ " يَا أَيُّهَا النَّاسُ إِنَّمَا الأَعْمَالُ بِالنِّيَّةِ وَإِنَّمَا لاِمْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ، فَهِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ، وَمَنْ هَاجَرَ إِلَى دُنْيَا يُصِيبُهَا أَوِ امْرَأَةٍ يَتَزَوَّجُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ " .
also referenced under: Book 90, Hadith 1 (In-Book) & Volume 9, Book 86, Hadith 85 (USC-MSA)