Sunan Ibn Majah, Volume 4, Book 24, Hadith 2783 (DarusSalam) ⓘ
It was narrated that Abu Musa said: “The Prophet was asked about a man who fights to prove his courage, or out of pride and honour for his close relatives, or to show off. The Messenger of Allah said: ‘Whoever fights so that the Word of Allah may be supreme is the one who (is fighting) in the cause of Allah.’”
حَدَّثَنَا مُحَمَّدُ بْنُ عَبْدِ اللَّهِ بْنِ نُمَيْرٍ، حَدَّثَنَا أَبُو مُعَاوِيَةَ، عَنِ الأَعْمَشِ، عَنْ شَقِيقٍ، عَنْ أَبِي مُوسَى، قَالَ سُئِلَ النَّبِيُّ صلى الله عليه وسلم عَنِ الرَّجُلِ يُقَاتِلُ شَجَاعَةً وَيُقَاتِلُ حَمِيَّةً وَيُقَاتِلُ رِيَاءً فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " مَنْ قَاتَلَ لِتَكُونَ كَلِمَةُ اللَّهِ هِيَ الْعُلْيَا فَهُوَ فِي سَبِيلِ اللَّهِ " .
also referenced under: Hadith 2783 (Reference) & Book 24, Hadith 2889 (In-Book)