An Arabi came to the Messenger of Allah ﷺ and said, "A man fights to be remembered, another fights for spoils, 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, he is in the path of Allah."
أخبرنا إسمعيل بن مسعود قال حدثنا خالد قال حدثنا شعبة أن عمرو بن مرة أخبرهم قال سمعت أبا وائل قال حدثنا
جاء أعرابي إلى رسول الله ﷺ فقال الرجل يقاتل ليذكر ويقاتل ليغنم ويقاتل ليرى مكانه فمن في سبيل الله قال من قاتل لتكون كلمة الله هي العليا فهو في سبيل الله عز وجل
Bukhari narrated it in the Book of Jihad, chapter "Whoever fights so that the word of Allah is uppermost," hadith 2810, and Muslim narrated it in the Book of Leadership, chapter "Whoever fights so that the word of Allah is uppermost is in the path of Allah," hadith 1904, both from the hadith of Shubah through this chain. It is also found in Al-Kubra, hadith 4344.