Punishments are what happen to people in return for their evil deeds. Trials are tests which are sent to try people, and people may be tested by good things or by bad.
Concerning punishments, Allaah says (interpretation of the meaning): “Whatever of good reaches you, is from Allaah, but whatever of evil befalls you, is from yourself…” [al-Nisa’ 4:79]
Concerning the phrase “is from yourself”, Qutaadah said: “[It means] the punishment is for you, O son of Adam, because of your sin.” Abu Saalih said that “whatever of evil befalls you, is from yourself” means “because of your sin, and I [Allaah] am the One Who decreed it for you.” (Tafseer Ibn Katheer).
Allaah also says (interpretation of the meaning): “And whatever of misfortune befalls you, it is because of what your hands have earned. And He pardons much.” [al-Shoora 42:30]
Ibn Katheer, may Allaah have mercy on him, said: “[It means] whatever misfortune happens to you, O people, is because of evil deeds that you have already done, and ‘He pardons much’ refers to evil deeds – He does not punish you for them but He pardons them. ‘And if Allaah were to punish men for that which they earned, he would not leave a moving (living) creature on the surface of the earth…’ [Faatir 35:45 – interpretation of the meaning].”
Concerning trials, the Prophet (peace and blessings of Allaah be upon him) said: “If Allaah loves a people, He tries them, and whoever has patience will have patience, and whoever is anxious will be anxious.” (Reported by Imaam Ahmad; Saheeh al-Jaami’, 1706).
The Prophet (peace and blessings of Allaah be upon him) also said: “The extent of the reward will be in accordance with the extent of the trial. If Allaah loves a people, He tries them, and whoever is content will have contentment, and whoever is angry will have anger.” (Reported by al-Tirmidhi, 2320; Saheeh al-Jaami’, 2210).
The following outlines how one may tell whether a given event is a punishment or a trial:
If the misfortune results from doing an act of obedience to Allaah, such as being wounded in jihaad, or losing money when migrating for the sake of Allaah, or losing a job because of becoming Muslim or increasing one’s commitment to Islam, then this is a trial. Whoever bears it with patience will be rewarded, but if one reacts angrily then one will earn the wrath of Allaah. If the misfortune results from sin, such as sexually-transmitted diseases or illnesses caused by drinking alcohol and taking drugs, and so on, then this is the kind of punishment that comes in this world (as opposed to being deferred until the Hereafter). If the misfortune is connected neither to a good deed nor a sin – such as other kinds of disease and sickness, losing a child, or failing in business – then it depends on the person’s situation. If he is good and devout, it is a trial, and if he is sinful, it is a punishment.
The misfortune may be a punishment to atone for sins, or it may be a trial aimed at raising a person’s status and increasing his hasanaat (good deeds/rewards) – this may be determined by whether a person is obedient or disobedient. A person should not praise himself, rather he should criticize himself for his shortcomings and strive to attain perfection. He will benefit from misfortunes in any case, if he has patience and hopes for reward.
And Allaah knows best.