Abu Musa Al-Ash'ari (May Allah be pleased with him) reported that Messenger of Allah (ﷺ) was asked about who fights in the battlefield out of valour, or out of zeal, or out of hypocrisy, which of this is considered as fighting in the cause of Allah? He said:
"He who fights in order that the Word of Allah remains the supreme, is considered as fighting in the cause of Allah".[Al-Bukhari and Muslim].
Arabic/English book reference: Book 1, Hadith 8