كتاب الإمارة
33  
The Book on Government
(42)
Chapter: One who fights so that the word of Allah will be supreme is fighting in the cause of Allah
(42)
باب مَنْ قَاتَلَ لِتَكُونَ كَلِمَةُ اللَّهِ هِيَ الْعُلْيَا فَهُوَ فِي سَبِيلِ اللَّهِ ‏‏
Sahih Muslim 1904 d

It has been narrated through a different chain of transmitters on the same authority, i. e. Abu Musa Ash'ari, that a man asked the Messenger of Allah (ﷺ) about fighting in the way of Allah, the Exalted and Majestic, a man who fights out of rage or out of family pride. He raised his head towards him-and he did so because the man was standing and said:

Who fights that the word of Allah be exalted fights in the way of Allah.
وَحَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، أَخْبَرَنَا جَرِيرٌ، عَنْ مَنْصُورٍ، عَنْ أَبِي وَائِلٍ، عَنْ أَبِي، مُوسَى الأَشْعَرِيِّ أَنَّ رَجُلاً، سَأَلَ رَسُولَ اللَّهِ صلى الله عليه وسلم عَنِ الْقِتَالِ فِي سَبِيلِ اللَّهِ عَزَّ وَجَلَّ فَقَالَ الرَّجُلُ يُقَاتِلُ غَضَبًا وَيُقَاتِلُ حَمِيَّةً قَالَ فَرَفَعَ رَأْسَهُ إِلَيْهِ - وَمَا رَفَعَ رَأْسَهُ إِلَيْهِ إِلاَّ أَنَّهُ كَانَ قَائِمًا - فَقَالَ ‏ "‏ مَنْ قَاتَلَ لِتَكُونَ كَلِمَةُ اللَّهِ هِيَ الْعُلْيَا فَهُوَ فِي سَبِيلِ اللَّهِ ‏"‏ ‏.‏
Reference : Sahih Muslim 1904d
In-book reference : Book 33, Hadith 217
USC-MSA web (English) reference : Book 20, Hadith 4687
  (deprecated numbering scheme)