Musnad Ahmad 300
حَدَّثَنَا يَزِيدُ ، أَنْبَأَنَا يَحْيَى بْنُ سَعِيدٍ الأَنصاري ، أَنَّ مُحَمَّدَ بْنَ إِبْرَاهِيمَ أَخْبَرَهُ، أَنَّهُ سَمِعَ عَلْقَمَةَ بْنَ وَقَّاصٍ اللَّيْثِيَّ ، يَقُولُ: إِنَّهُ سَمِعَ عُمَرَ بْنَ الْخَطَّابِ وَهُوَ يَخْطُبُ النَّاسَ، وَهُوَ يَقُولُ: سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ، يَقُولُ:" إِنَّمَا الْعَمَلُ بِالنِّيَّةِ، وَإِنَّمَا لِامْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللَّهِ وَإِلَى رَسُولِهِ، فَهِجْرَتُهُ إِلَى اللَّهِ وَإِلَى رَسُولِهِ، وَمَنْ كَانَتْ هِجْرَتُهُ لِدُنْيَا يُصِيبُهَا، أَوْ امْرَأَةٍ يَتَزَوَّجُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ".
Yazid narrated to us; he said: Yahya ibn Saʿid al-Ansari informed us that Muhammad ibn Ibrahim informed him that he heard ʿAlqamah ibn Waqqas al-Laythi say that he heard ʿUmar ibn al-Khattab, while he was addressing the people, say: I heard the Messenger of Allah ﷺ say: "Deeds are only by intention, and each person will have only what he intended. So whoever's emigration was to Allah and His Messenger, his emigration is to Allah and His Messenger; and whoever's emigration was for some worldly gain he would get, or a woman he would marry, his emigration is to that for which he emigrated."