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."
جاء رجل إلى النبي ﷺ فقال: الرجل يقاتل للمغنم، والرجل يقاتل للذكر، والرجل يقاتل ليرى مكانه فمن في سبيل الله؟ قال: من قاتل لتكون كلمة الله هي العليا فهو في سبيل الله.
Bukhari narrated it in Jihad (2810), and Muslim in Imarah (1904:149), both through Shuba, from Amr bin Mura, who said, I heard Abu Waail say, Abu Musa Ashari narrated to us, and he mentioned it.