Musnad Ahmad 300
`Alqamah bin Waqqas al Laithi said that he heard `Umar bin al-Khattab addressing the people, and he said:
I heard the Messenger of Allah (ﷺ) say: “Action is but by intention and each person will have but that which he intended. So whoever migrated for the sake of Allah and His Messenger, then his migration was for the sake of Allah and His Messenger, whoever migrated for some worldly purpose or for the sake of a woman whom he could marry, his migration was for the purpose for which he migrated.”
حَدَّثَنَا يَزِيدُ، أَنْبَأَنَا يَحْيَى بْنُ سَعِيدٍ، أَنَّ مُحَمَّدَ بْنَ إِبْرَاهِيمَ، أَخْبَرَهُ أَنَّهُ، سَمِعَ عَلْقَمَةَ بْنَ وَقَّاصٍ اللَّيْثِيَّ، يَقُولُ إِنَّهُ سَمِعَ عُمَرَ بْنَ الْخَطَّابِ، رَضِيَ اللَّهُ عَنْهُ وَهُوَ يَخْطُبُ النَّاسَ وَهُوَ يَقُولُ سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ يَقُولُ إِنَّمَا الْعَمَلُ بِالنِّيَّةِ وَإِنَّمَا لِامْرِئٍ مَا نَوَى فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللَّهِ وَإِلَى رَسُولِهِ فَهِجْرَتُهُ إِلَى اللَّهِ وَإِلَى رَسُولِهِ وَمَنْ كَانَتْ هِجْرَتُهُ لِدُنْيَا يُصِيبُهَا أَوْ امْرَأَةٍ يَتَزَوَّجُهَا فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ‏.‏