Abu Musa Ashari reported,

A man came to the Prophet ﷺ and asked, "A man fights out of tribal loyalty, another fights out of bravery, and another fights to be seen. 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."

Bukhari 7458

Sahih

حدثنا محمد بن كثير حدثنا سفيان عن الأعمش عن أبي وائل

عن أبي موسى قال

جاء رجل إلى النبي ﷺ فقال الرجل يقاتل حمية ويقاتل شجاعة ويقاتل رياء فأي ذلك في سبيل الله قال من قاتل لتكون كلمة الله هي العليا فهو في سبيل الله

البخاري 7458صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Tawhid
Chapter
His saying, "And Our word has already preceded for Our servants, the messengers"
Numbering
Darussalam 7458
Bukhari 7458