Al-Imām An-Nawawī, may Allah have mercy on him, writes:
"Know that what we mentioned regarding the excellence of seeking knowledge, then that is only for those who seek it intending to see the Face of Allah (in Jannah), and do not have a worldly ambition. The one who has a worldly ambition like wealth, leadership, position, power, notiriety, gaining a people's loyalty, overcoming opponents, or anything similar to this, then this is reprehensible."
Al-Majmū' (1/46)