Praise be to Allaah.
Allaah says (interpretation of the meaning):
O you who believe! Be afraid of Allaah and give up what remains (due to you) from Ribaa (from now onward) if you are (really) believers
This is a call from Allaah to give up riba and avoid it, because He has forbidden riba:
Allaah has permitted trading and forbidden Ribaa
[al-Baqarah 2:275 - interpretation of the meaning]
Consumption of riba is one of the causes of the humiliation of the Muslims, as the Prophet (peace and blessings of Allaah be upon him) said: If you engage in eenah transactions, and are content with farming and hold on to the tails of cattle, and you forsake jihad for the sake of Allaah, Allaah will cause you to be humiliated and will not relieve you of that until you return to your religion.
Narrated by Abu Dawood, 3462; classed as saheeh by al-Albaani in al-Silsilah al-Saheehah, 11.
[Translator's note: eenah transaction means to sell something for a price to be paid at a later date, then to buy it back for a lower price (to be paid immediately); this is a trick used to circumvent the prohibition on lending with interest]
The issue of buying shares in riba-based banks has been discussed previously. Please see questions nos. 8590 and 4714
With regard to the fast of one who commits a major sin - such as buying shares in a riba-based bank - it is valid but is imperfect, and he may not attain the reward of fasting.
Think about the words of Allaah (interpretation of the meaning):
O you who believe! Observing As-Sawm (the fasting) is prescribed for you as it was prescribed for those before you, that you may become Al-Muttaqoon (the pious)
In this verse Allaah mentions the reason why fasting is enjoined, which is as a means of fearing Allaah by doing obligatory duties and avoiding haraam things.
The Prophet (peace and blessings of Allaah be upon him) said: Whoever does not give up false speech and acting upon it, Allaah has no need of his giving up his food and drink. Narrated by al-Bukhaari, 1903. in other words, Allaah does not simply mean that we should give up our food and drink when fasting, rather He wants us to fear Him, because He says (interpretation of the meaning):
â€¦ that you may become Al-Muttaqoon (the pious)
See al-Sharh al-Mumti', 6/435
Al-Haafiz ibn Hajar (may Allaah have mercy on him) said: false speech and acting upon it - what is meant by false speech is lying, and acting upon it means doing what is implied by that.
Ibn al-Arabi said: what is meant by this hadeeth is that whoever does what is mentioned will not be rewarded for his fasting; the reward for fasting is not cannot outweigh the sin of false speech etc.
Al-Baydaawi said: the purpose behind the prescription of fasting is not just to be hungry and thirsty, rather the purpose is what that leads to of suppressing desires and taming one's evil inclinations. If this is not achieved, then Allaah will not regard it as acceptable.
It was understood from this that these actions invalidate the fast.
From Fath al-Baari..