Shaykh al-Islaam Ibn Taymiyyah (may Allah have mercy on him) said: The punishment or a sin committed by a believer is removed in 10 ways:
1. He repents to Allaah (Tawbah), so Allah accepts his repentance, for the one who repents from sin is like the one who has no sin.
2. He seeks forgiveness from Allah (Istighfaar), so Allah forgives him.
3. He does good deeds that erase his sin for good deeds erase bad ones.
4. His believing brethren pray for him or seek forgiveness for his sins during his life or death.
5. Or they [ask Allaah] to bestow on him as gift from the reward for their deeds, with which Allaah benefits him.
6. His Prophet Muhammad (sallallahu `alayhi wa sallam) intercedes for him.
7. Allaah tests him with trials in this world which expiate his sin.
8. Allaah tests him in al-Barzakh (the intermediate life in the grave, between the death and the Day of Judgment) which expiates his sin.
9. Allaah tests him in the various stages of the Day of Judgment which expiates his sins.
10. Or the Most Merciful of those who have mercy has mercy on him.
Whoever, then, is missed by these ten cannot blame anyone but himself.
Majmoo` al-Fatawa 1:45, 7:487