Question: Is it permissible for a person to perform acts of worship while their heart is distracted and without sincerity?
Answer of Imam Abu Hamid Al-Ghazali (رحمه الله):
Imam Al-Ghazali teaches that the true value of worship is not merely in the outward actions of the body, but also in the sincerity (Ikhlās) and presence of the heart.
A person may perform many acts of worship, but if they are seeking praise, recognition, or admiration from people, their worship is in danger of becoming contaminated by riya’ (showing off).
He emphasizes that a servant should purify their intention and worship Allah sincerely, seeking His pleasure alone.
A lesson from Imam Al-Ghazali:
The heart is the essence of worship. Purify your intention, for Allah looks at your hearts and deeds.
Reference: Imam Al-Ghazali, Ihya’ Ulum al-Din (إحياء علوم الدين), Book of the Secrets of Worship and the Treatment of Riya’ (كتاب ذم الجاه والرياء).