Abu Musa Ashari reported,

A man came to the Prophet ﷺ and asked, "One man fights for the spoils, another fights for fame, and another fights to be seen for his position. Which of them 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."

Azami 7799

Sahih

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

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

الأعظمي 7799صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Jihad
Chapter
Rulings on jihad and its etiquette
Section
Whoever fights so that the word of Allah may be supreme
Numbering
Jami al-Kamil 7799 (2nd edition)
Azami 7799