Abu Musa Ashari reported,

A man came to the Prophet ﷺ and said, "One man fights for spoils, another fights for fame, and another fights to be seen in his position. Which of them fights in the cause of Allah?"He replied, "Whoever fights so that the word of Allah may be supreme, he is in the cause of Allah."

Bukhari 2810

Sahih

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

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

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

البخاري 2810صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Jihad and expeditions
Chapter
Whoever fights so that the word of Allah may be supreme
Numbering
Darussalam 2810
Bukhari 2810