Sahih Muslim , Book 20, Hadith 4684 (USC-MSA)

It has been narrated on the authority of Abu Musa Ash'ari that a desert Arab came to the Prophet and said: Messenger of Allah, one man fights fgr the spoils of war; another fights that he may be remembered, and another fights that he may see his (high) position (achieved as a result of his valour in fighting). Which of these is fighting in the cause of God? The Messenger of Allah said: Who fights so that the word of Allah is exalted is fighting in the way of Allah.

حَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، وَابْنُ، بَشَّارٍ - وَاللَّفْظُ لاِبْنِ الْمُثَنَّى - قَالاَ حَدَّثَنَا مُحَمَّدُ، بْنُ جَعْفَرٍ حَدَّثَنَا شُعْبَةُ، عَنْ عَمْرِو بْنِ مُرَّةَ، قَالَ سَمِعْتُ أَبَا وَائِلٍ، قَالَ حَدَّثَنَا أَبُو مُوسَى، الأَشْعَرِيُّ أَنَّ رَجُلاً، أَعْرَابِيًّا أَتَى النَّبِيَّ صلى الله عليه وسلم فَقَالَ يَا رَسُولَ اللَّهِ الرَّجُلُ يُقَاتِلُ لِلْمَغْنَمِ وَالرَّجُلُ يُقَاتِلُ لِيُذْكَرَ وَالرَّجُلُ يُقَاتِلُ لِيُرَى مَكَانُهُ فَمَنْ فِي سَبِيلِ اللَّهِ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ مَنْ قَاتَلَ لِتَكُونَ كَلِمَةُ اللَّهِ أَعْلَى فَهُوَ فِي سَبِيلِ اللَّهِ ‏" ‏ ‏.‏

sunnah.com