All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu 'alyhi wa sallam, is His slave and Messenger.
We should differentiate between two things:
First: The stolen capital, which you must exert your utmost effort to return to its owner, according to the consensus of scholars. If he has died, you must give it to his heirs. If there are no heirs or it is difficult to reach them, then you should give the money in charity on their behalf. If you come across the claimant later on and he approves of the charity, then you are not liable to pay him the money. If he does not approve of it, then you must return the money to him.
Second: The profit that resulted from investing the stolen money: Should you deal with it as you dealt with the capital? Are you entitled to the profit on the grounds of the efforts which you have made? Scholars of Fiqh (jurisprudence) have two points of view regarding this issue.
The first: The profit follows the capital and not the effort exerted if it was taken without the permission of its owner, and the taker is not entitled to anything thereof. This is the saying of Imaam Abu Haneefah and Imaam Ahmad according to the preponderant opinion of his school of Fiqh. This is also the view of Ibn Hazm .
The second: The profit follows the effort exerted, not the capital, and thus the profit resulting from the investment of ill-gotten money will be the right of the taker not the right of the original owner of the capital. This is the saying of the Maaliki and Shaafi‘i scholars who provided as evidence the Hadeeth of the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, where he said: “The revenue goes with the liability.” [Ahmad] [Abu Daawood, An-Nasaa’i, At-Tirmithi and Ibn Maajah] [Ibn Al-Qattaan: Saheeh (Authentic)]
The first saying, and Allaah knows best, takes precedence over the second saying. Hence, you must return the capital and the profit to the owner. This precedence was explained by Imaam Ash-Shawkaani who said, “The profit arising from a usurped item follows it. Just as the usurped item must be returned to the owner, the profit must be returned to him as well. Arguments indicating otherwise are not supported by evidence from Hadeeths and their exegesis. However, providing as evidence the Hadeeth that says: “The revenue goes with the liability” is not correct, because it should be quoted in relation to an item that has been received with the permission of its owner. How could a usurped item be dealt with in the same way?”
In short, adopting the first saying that we mentioned of the scholars complies with the rules and objectives of the Sharee‘ah. A wrongdoer should not benefit from his wrongdoing, because one of the objectives of the Sharee‘ah is to prevent aggression and to block the means leading to it. Saying that a wrongdoer is entitled to the profit of the money that he unrightfully stole or usurped contradicts this objective of the Sharee‘ah. Were it to be allowed, then usurpation and theft would be a means of making lawful gains, and this is not ordained by the Sharee‘ah.
Finally, you must get rid of the money and the profit and diligently seek the original owner of the money or his heirs, even if you have to spend some of this money to reach them. You should hasten to do that before death overtakes you and prevents you from disposing of these accumulated rights.
Allaah Knows best.