Praise be to Allah.
First of all, we thank the questioner for his high level of concern towards all people, and his love of good for them and his desire to ward off evil and sin from them, and especially for his understanding of the responsibility of calling non-Muslims to Islam in all interactions, even if that is at one’s own cost. We ask Allah, may He be exalted, to reward you and to help us and you to do all that is good.
It is well known in fiqh that contracts based on haram matters are invalid contracts; what results from them is not binding, and the burden of sin rests on all parties to the contract. One of the consequences of their invalidity is that ownership is not transferred by means of such contracts, and that the price must be returned to the one who paid it, so long as he has not used or benefited from what he purchased - although there is a difference of opinion among the scholars – because the transaction is invalid in the first place.
This ruling is also applicable to the purchase of shares in companies whose activities are haram, such as riba-based (usurious) banks, companies that sell alcohol and pork, tobacco companies, gambling companies, companies that deal in degenerate art, and the like. If anyone purchases shares in them, his purchase is invalid. Sincere repentance from this sin requires giving up any civil obligations entailed in this contract, because repentance cancels out what came before it. Allah, may He be glorified and exalted, says (interpretation of the meaning): “but if you repent, you shall have your capital sums. Deal not unjustly (by asking more than your capital sums), and you shall not be dealt with unjustly (by receiving less than your capital sums)” [al-Baqarah 2:279].
If the company recognizes that the purchase was invalid and agrees to return the money voluntarily – but this usually does not happen except in the case of limited shareholder companies – then the repentant shareholder is entitled to take back what is rightfully his, by canceling the share transaction with the haraam company itself. So he may take back his capital, but anything surplus to that he must spend on charitable causes; it is not permissible for him to benefit from it. And he must still repent and pray for forgiveness in order to expiate that sin.
But if the company or the body that regulates the stock market does not acknowledge that the sale and purchase of shares in haraam companies is invalid, or the company has public ownership and it is not possible to get rid of the shares except by reselling them in the financial market, then we have two options:
1. To keep them, which is persisting in sin, because the shareholder is a partner to the haraam actions that are going on in the company, in addition to the fact that keeping the shares is participating in transmission of something haraam to his heirs after his death;
2. Or to get rid of them by selling them in the stock market.
In this case the second option, even though it is not free of some objectionable matters such as helping someone else to engage in the haraam partnership, is less serious than the first option.
Hence the Standing Committee ruled that they may be sold in order to get rid of them, as we have quoted in their fatwa in the answer to question no. 35726.
And Allah knows best.