Praise be to Allah.
It is not permissible to buy shares in riba-based banks or in companies that are based on riba, because that is consuming riba, and the Messenger of Allaah (peace and blessings of Allaah be upon him) cursed the one who consumes riba and the one who pays it. Narrated by Muslim (1597).
In a statement issued by the Islamic Fiqh Council during its seventh conference, held in Jeddah in 1412 AH, it says:
There is no dispute that shares in companies whose basic aims are haraam, such as dealing with riba, producing haraam things or dealing in haraam things, are also haraam. End quote.
Majallat al-Majma’ al-Fiqhi, no. 7, vol. 1, p. 711
If a person has bought these shares, he has to repent to Allaah by regretting what he has done, resolving not to do it again, and getting out of the company or bank, and selling these shares. He is not entitled to anything more than his capital, and whatever is greater than his capital he must spend it on charitable causes.
The scholars of the Standing Committee were asked: I had some shares in a company, and this company went bankrupt 25 years ago. There were trustees of the company who bought into the Riyadh bank with what was left of the shares, 25 years ago, each share costing 1000 riyals. Now the price of one share is 30,000 riyals. I need this money, so is it permissible to take the current value of the share, knowing that they bought these shares in the Riyadh bank without us knowing all this time? They replied: You should take the entire amount, the capital and the interest, then keep the capital, because that belongs to you, and give the interest in charity, because it is riba. Allaah will make you independent of means by His bounty, and will compensate you with something better than it, and He will help you to meet your needs.
“And whosoever fears Allaah and keeps his duty to Him, He will make a way for him to get out (from every difficulty).
3. And He will provide him from (sources) he never could imagine. And whosoever puts his trust in Allaah, then He will suffice him.”
End quote. Fataawa al-Lajnah al-Daa’imah (13/506)
It also says in Fataawa al-Lajnah al-Daa’imah (13/508): It is not permissible to buy shares in banks or companies that deal with riba. If our correspondent wants to get rid of his riba-based shares, he may sell them at the market price, then keep his original capital only; the rest he should spend on charitable causes. It is not permissible for him to take any of the interest or riba-based profits of his shares. But if the shares were in a company that does not deal in riba, then the profits on them are halaal. End quote.
And Allaah knows best.