The roots of Sufism lie embedded in Islam itself. There are numerous passages in the Holy Quran which are of a mystical character. The Holy Prophet of Islam (peace be on him) himself displayed mystical inclinations and he very often retired to the cave of Hirah for the purpose of devotions, meditation and contemplation. The Holy Prophet was recipient of two types of revelations, one embodied in the Holy Quran, and the other that illuminated his heart. The former was meant for all, the latter for a selected few whose hearts could be illuminated with the Divine Light. The knowledge of the Holy Prophet was thus book knowledge (ilm-i-Safina), and heart knowledge (ilm-i-Sina). Ali got this heart knowledge from the Holy Prophet. It is related that after the Ascension, the Holy Prophet awarded a mantle to Ali which led to the illumination of his heart.
"When a person dies, his works end, except for three: ongoing charity, knowledge that is benefited from, and a righteous child who prays for him."
Prophet Mohammed (PBUH)
"The best of what a man leaves behind are three: a righteous child who supplicates for him, ongoing charity the reward of which reaches him, and knowledge that is acted upon after him."
Sunan Ibn Mājah
"Every day two angels come down from Heaven and one of them says, 'O Allah! Compensate every person who spends in Your Cause,' and the other (angel) says, 'O Allah! Destroy every miser.'"
Sahih Bukhari