Fasting Ramadan is the fourth pillar in Islam and requires the believer to refrain from eating, drinking or engaging in sexual activity from dawn to dusk. It is also necessary for the heart to be fully engaged in this worship through having a sincere intention of purifying one's soul and elevating one's spiritual state with God through refraining from paying the regular attention to the needs of the body.
A lot of scholars have focused on ways to purify the heart during Ramadan and one of the luminary scholars, Imam Abu Hamid al- Ghazali, drew a blueprint for the believer to benefit the most out of Ramadan and to reach his full potential of cleansing his soul and purifying his heart through attaching it to God and to set himself free from the shackles of bodily and earthly bounds.
Al- Ghazalī paid extra attention to the issue of polishing the heart to prepare it for the divine presence. For this reason he cited some necessary elements to guard the heart against the imprints of the senses. The first element he cited is lowering the gaze and restraining it from widely looking at what is detested and disapproved along with whatever would lead to the distraction of the heart away from the remembrance of God. The second element is guarding the tongue from hallucination, lying, backbiting, gossiping, obscenity, brusqueness and enmity. The heart instead should be occupied with the remembrance of God and reciting the Quran. The third element is preventing the ears from hearing anything that is detested because anything that is forbidden to be said is forbidden to be heard. The forth element is guarding the limbs from engaging in unlawful detestable acts along with not allowing any unlawful food to have a way to the stomach. The unlawful food for Sufism is breaking one's fast through gossiping or through committing sinful acts. The fifth element is holding back from filling the stomach with lawful food when the wayfarer breaks his fast. The reason behind fasting is to break lustful urges of the self which increase with unrestrained eating. The last element is when the wayfarer breaks his fast; his heart needs to cling to both the hope of acceptance of his fasting and the fear of being rejected.
Al Ghazalī explained further the purpose of fasting for Sufis is to have one of the God-like moralities al samadiyyah which means not eating or drinking. Also fasting is highly favored because it is the kind of worship that can easily be done in secrecy without the knowledge of anyone save God. Ibn 'Arabī explored the reason behind God's saying "Fasting is a deed done for My Sake and I am the one who gives its reward". In this hadith qudsī God elevated the status of fasting over other forms of ritual worship through negating similarities between fasting and other kinds of worship. The negation of similarities places fasting in a unique position just like God having no similarities with anything. Therefore, the common factor of uniqueness and denying similarities nafy al methleyah strengthen the relevancy of fasting to God. Ibn 'Arabī elaborated further on this point and said that fasting is actually not a worship nor an act to do, it is more like refraining from doing so the real truth of fasting is kept secret and therefore God is the one who will reward for it.
Also fasting aims at being angel- like in restraining oneself from indulging in lusts as the human being is positioned in a degree above animals because of his intellectual capacity which enables him to be in control over his lusts and in a degree below the angels who by nature do not have an intrinsic desire for lusts in the first place. The higher the degree the wayfarer reaches, his chances increase in getting closer to the realm of the angels; a status which leads him to closeness to God.
Sufi Saints explained further how fasting and hunger purify the heart and restrain the lusts of the lower self. Dhu al Nun al Masry said in this regard that whenever he ate to his full or drank till he quenched his thirst, he would commit a sin or was about to. Lady Aysha, the Prophet's wife, said "keep knocking at the doors of heaven and it will open up to you" so she was asked how to keep knocking and she replied "with hunger and thirst". These sayings have strong roots in the prophetic traditions as it was narrated numerously by lady Aysha that the Prophet never had his stomach full from wheat bread three days in a row. Also she said that sometimes more than a month and a half would pass by without fire being lit in the Prophet's house and all they had was dates and water. 
Abdel Qāder al Jilānī marked the difference between the religious and the spiritual fasting by saying that the religious fasting is limited by time while the spiritual one lasts through one's temporal and eternal life. The highest kind of fasting is the fast of truth which is preventing the heart from worshiping anything save God. For Sufis there is nothing that one can wish for or aim to achieve more desirable than attaining the love of God. Therefore if an atom of anything other than the love of God enters the heart the fast of truth is broken and the vows of love need to be renewed.
Abū Ḥafs al- Suhrawardī.‘Awaref al Ma‘āref. 1st ed (Beirut: Dar al Kitab al- ‘Arabī, 1966) 327
 Mohyī al- Dīn Ibn ‘Arabi. Al- Futūhāt al Makkiyah. Vol 1(Cairo: Dar al Kutub al ‘Arabiyah al Kubrah,ND) 602
, Abū Ḥamidal- Ghazālī. Iḥyāʾ ‘ulūm al- dīn. Vol.1 (Cairo: Al Maktabah Al Tawfiqiya, ND) 359
Abū Ḥafs al- Suhrawardī.‘Awaref al Ma‘āref. 1st ed (Beirut: Dar al Kitab al- ‘Arabī, 1966) 328
Abdel karīm al- Jīlī. Al-Insān al Kāmel. (Cairo: al- Matba‘ah al- ‘Amerah al Sharqiyah, 1882) 82-83