The Prophet ﷺ said, "There is no envy except in two cases. A man whom Allah has given wealth and who spends it in the cause of truth, and a man whom Allah has given wisdom, who judges by it and teaches it to others."
قال النبي ﷺ: لا حسد إلا في اثنتين: رجل آتاه الله مالا فسلط على هلكته في الحق، ورجل آتاه الله الحكمة فهو يقضي بها ويعلمها.
Bukhari related it in the chapter on zakat (1409), and Muslim related it in the chapter on the prayer of travelers (816), both from the hadith of Ismail, from Qays bin Abu Hazim, who said, I heard Abdullah bin Masud say, and then he mentioned it.The envy mentioned in this hadith refers to "ghibtah" (with a kasrah on the ghayn), which is to wish for a condition like that of the envied person without wanting it taken away from him. This is not the blameworthy kind of envy.