صحيح مسلم
Sahih Muslim
كتاب الإمارة
The Book on Government
باب قَوْلِهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِنَّمَا الأَعْمَالُ بِالنِّيَّةِ». وَأَنَّهُ يَدْخُلُ فِيهِ الْغَزْوُ وَغَيْرُهُ مِنَ الأَعْمَالِ:
Chapter: The words of the prophets saws: "Deeds are but with intentions" which includes fighting and other deeds
2 hadith
Hadith 1907
It has been narrated on the authority of Umar bin al-Khattab that the Messenger of Allah (ﷺ) said: (The value of) an action depends on the intention behind it. A man will be rewarded only for what he intended. The emigration of one who emigrates for the sake of Allah and His Messenger (ﷺ) is for the sake of Allah and His Messenger (ﷺ) ; and the emigration of one who emigrates for gaining a worldly advantage or for marrying a woman is for what he has emigrated.
Hadith 1907
It has been narrated through a different chain of transmitters on the authority of Sufyan who said that he heard 'Umar bin al-Khattab relate (this tradition) from the Holy Prophet (ﷺ) while he was delivering a sermon from the pulpit.