There are many things which expiate for sins, including repentance, seeking forgiveness, doing acts of worship, carrying out hadd (Islamically prescribed) punishments on those who have done acts for which such punishments are due, and so on. But righteous deeds such as prayers, fasting, Hajj, etc. only expiate for minor sins, according to the majority of scholars, and they only expiate for transgressions against the rights of Allah. With regard to sins that have to do with the rights of other people, they can only be expiated by repenting from them. One of the conditions of repenting from them is restoring the rights of those who have been wronged.
Muslim narrated from ‘Abd-Allah ibn ‘Amr ibn al-‘As (may Allah be pleased with him) that the Messenger of Allah (peace and blessings of Allah be upon him) said: “The martyr will be forgiven for all his sins except debt.”
Al-Nawawi said in Sharh Muslim:
The words of the Prophet (peace and blessings of Allah be upon him) “except debt” draw attention to all rights owed to other people. Jihad (fighting for Allah’s cause), martyrdom and other righteous deeds do not expiate for transgressions against the rights of other people, rather they only expiate for transgressions against the rights of Allah. End quote.
Ibn Muflih said in al-Furoo’.
Martyrdom expiates for everything except debt. Our Shaykh (i.e., Shaykh al-Islam Ibn Taymiyah, may Allah have mercy on him) said: and except sins against other people such as murder and oppression. End quote.
It says in al-Mawsoo’ah al-Fiqhiyyah: Repentance in the sense of regretting what one has done and resolving not to do it again is not sufficient to waive the rights that are owed to other people. Whoever has stolen another person’s wealth, or seized it by force, or has wronged him in any other way, will not have finished with the matter by simply regretting it, giving up the sin and resolving not to do it again. Rather he has to restore those rights. This is a principle on which the fuqaha (jurists) are unanimously agreed. End quote.
This has to do with material possessions, such as wealth that has been taken by force or by deceit. With regard to intangible rights such as in cases of slander and backbiting, if the person who has been wronged knows about it, then it is essential to apologize to him and ask for his forgiveness. If he does not know, then he should not be told; rather the one who wronged him should pray for him and pray for forgiveness for him, because telling him may upset him and create enmity and hatred between the two.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: According to the saheeh hadeeth (authentic narration): “Whoever has wronged his brother with regard to his blood, his wealth or his honour, let him come and set matters straight before there comes a Day on which there will be no dirhams and no dinars, only good deeds and bad deeds, and if he has good deeds (they will be taken and given to the one whom he wronged), otherwise some of the bad deeds of the one whom he wronged will be taken and added to his burden, then he will be thrown into the Fire.” This has to do with cases where the one who was wronged was aware of it; but if he was gossiped about or slandered and he does not know, then it was said that one of the conditions of repentance is telling him, or it was said that this is not essential, which is the view of the majority; both views were narrated from Ahmad, but his view on such matters is that one should do good deeds for the one who was wronged, such as praying for him, praying for forgiveness for him and doing good deeds to be given to him, to take the place of that backbiting and slander. Al-Hasan al-Basri said: The expiation for gossip is to pray for forgiveness for the person about whom you gossiped. End quote.
The scholars of the Standing Committee said, concerning a man who stole money from a slave:
If he knows the slave or he knows someone who knows him, he can tell him to look for him and give him the money in silver or the equivalent, or whatever he agrees upon with him. If he does not know who he is and he thinks that he will never find him, he should give it or the equivalent in cash to a charity on behalf of its owner. If he finds him after that, he should tell him what he did; if he accepts that, all well and good, but if he objects and demands his money, then he should give it to him, and the money he gave in charity becomes an act of charity on his own behalf. He also has to ask Allah for forgiveness and repent to Him, and pray for the other person.
And Allah knows best.