The Messenger of Allah ﷺ was asked about a man who fights out of bravery, a man who fights out of zeal for his tribe, and a man who fights to show off. Which of these is in the path of Allah?He replied, "Whoever fights so that the word of Allah may be supreme is in the path of Allah."
حدثنا هناد حدثنا أبو معاوية عن الأعمش عن شقيق بن سلمة
سئل رسول الله ﷺ عن الرجل يقاتل شجاعة ويقاتل حمية ويقاتل رياء فأي ذلك في سبيل الله قال من قاتل لتكون كلمة الله هي العليا فهو في سبيل الله
Agreed upon [Muslim, al-Imarah, chapter on one who fights so that Allah's word may prevail, no. 1904, from the hadith of Abu Muawiya al-Darir, and Bukhari, no. 7458, from the hadith of Amash through the same route].In this chapter, there is also a hadith from Umar [to come at no. 1647].