Almighty Allah says (what can be translated as): “O you who have believed, do not make allies of a people with whom Allah has become angry. They have despaired of [reward in] the Hereafter just as the disbelievers have despaired of [meeting] the inhabitants of the graves.” (Al-Mumtahanah: 13)
After the previous command to the believers not to take Allah’s enemies and their enemies as allies and not to extend affection to them in the beginning of the Surah, Almighty Allah confirms this command by calling the believers not to make allies of a people with whom Allah has become angry and so they deserve to be deprived of Allah’s mercy. Allah orders them not to take friends from those disbelievers or tell them things that harm Islam and Muslims. Those disbelievers are hopeless of the reward and survival in the Hereafter because of their stubbornness and insistence on disbelieving and denying Allah’s Messenger, just as they are hopeless of meeting and seeing the dead in the Hereafter because they do not believe in the resurrection and judgment of the people by Almighty Allah.
The people with whom Allah has become angry are the polytheists in general starting with the Jews because they are often described that way.
It was reported that the reason for revealing this verse is that a group of poor Muslims used to be friendly with the Jews in Madhinah to get some of their fruits and they might have reported to them some of the affairs of Muslims, so this verse was revealed to forbid them from doing so.
O you who truly believed in Allah Almighty, He forbids you from taking the people with whom Allah has become angry as allies and friends, He forbids you from telling them the secrets of Muslims and share with them things that they should not know about.
“They have despaired of [reward in] the Hereafter just as the disbelievers have despaired of [meeting] the inhabitants of the graves.” (verse 13): This verse explains why the believers are forbidden to take the disbelievers as allies and are discouraged to depend on them. Desperation is the loss of hope or lack of expectation that something would ever happen. The meaning is that Allah has become angry with the Jews, Christians and the rest of the disbelievers because they despaired of working for the Hereafter. They preferred the worldly life and despaired of the eternal life just as the disbelievers have despaired of those buried in graves to be brought back to life for resurrection and judgment because they neither believe in resurrection after death nor reward and punishment as depicted in the Quran in so many verses such as: “They said, when we have died and become dust and bones, are we indeed to be resurrected?” The verse assimilates the condition of those Jews in refusing to believe and work for the Hereafter to the condition of the disbelievers in denying the resurrection of the dead from their graves on the Judgment Day.
There is a link between “..the inhabitants of the graves.”, “have despaired” and “of” in the verse, the meaning can be that those with whom Allah has become angry have despaired of the Hereafter just as the disbelievers have despaired of the resurrection of the dead, and it can also mean that those with whom Allah has become angry have despaired of the Judgment Day just as the dead disbelievers in the graves hade been hopeless of getting some mercy, less torture or coming back to life to make some good deeds instead of their bad deeds that led to such punishment and torture.
Both meanings agree with the command in the verse which forbids the believers to take allies from the people with whom Allah has become angry. This meaning is conveyed in the most eloquent style and clarity. The verse describes those people as surrounded with the wrath of Allah Almighty because of their disobedience, rejection to Allah’s commands and denial of the Afterlife, Judgment Day and retribution.knowing Allah.com