In the light of the Quran and the sunnah, what to do when you feel envious?

Envy is a disease of the heart that causes a person to wish for the loss or removal of a blessing, talent, or merit that Allah has bestowed on another person. Envy is a sign of ingratitude and discontentment with the decree of Allah, and it can lead to many other sins such as hypocrisy, backbiting, slander, and oppression. Envy can also harm the envious person himself, as it consumes his good deeds and causes him distress and misery.

The Quran and the sunnah teach us how to deal with envy and protect ourselves from its evil effects. Here are some practical steps that we can take when we feel envious of someone:

- Seek refuge in Allah from the accursed Satan, who whispers evil thoughts into our hearts and tries to make us unhappy with what Allah has given us. Say: 

"أعوذ بالله من الشيطان الرجيم" 

(I seek refuge in Allah from the accursed Satan).

- Recite the last two surahs of the Quran, Al-Falaq and An-Nas, which are known as the Mu'awwidhatayn (the two protective surahs). These surahs seek Allah's protection from various evils, including the evil eye and envy. Say: "Qul a'udhu bi rabbil-falaq ... Qul a'udhu bi rabbin-nas" (Say: I seek refuge in the Lord of daybreak ... Say: I seek refuge in the Lord of mankind).

- Make du'a to Allah to bless the person whom you envy and to increase him or her in goodness. This will help you to purify your heart from malice and resentment, and to show sincerity and goodwill towards your fellow Muslim. Say: 

اللَّهُمَّ بَارِكْ لَهُ (أَوْ لَهَا) وَزِدْهُ (أَوْ زِدْهَا) خَيْرًا

"Allahumma barik lahu (or laha) wa zidhu (or zidha) khayran" 

(O Allah, bless him or her and increase him or her in goodness).

- Remind yourself of the blessings that Allah has given you, and thank Him for them. Counting your blessings will make you realize how generous and merciful Allah is to you, and how unworthy you are of His favors. This will also make you content and satisfied with what you have, and prevent you from coveting what others have. Say:

الحمدُ لله على كُلِّ نِعْمَة

 "Alhamdulillah 'ala kulli ni'mah" 

(All praise is due to Allah for every blessing).

- Seek knowledge and act upon it, as this will increase your faith and wisdom, and help you to overcome your lower desires. The Prophet (peace be upon him) said:

مَنْ سَلَكَ طَريقا يَبْتَغي فيه عِلْما سَهَّل الله له طريقا إلى الجنة

 "Whoever follows a path in pursuit of knowledge, Allah will make easy for him a path to Paradise." (Sahih Muslim) 

Study the Quran and the sunnah, and learn from the examples of the righteous predecessors who were free from envy and who loved for their brothers what they loved for themselves.

Imam Ghazali distinguished between envy and ghibtah, which is to wish for something good that someone else has without wishing them to lose it. He said that ghibtah is permissible and praiseworthy, as long as it does not lead to arrogance or resentment. He quoted another hadith of the Prophet Muhammad (peace be upon him) that said: 
“There is no envy except in two cases: a man whom Allah has given wealth and he spends it in the right way, and a man whom Allah has given wisdom and he judges by it and teaches it.” (Bukhari and Muslim)