The polytheistic religions and Judaism...
The polytheistic religions and Judaism, Christianity, Zoroastrianism, and Islam all have believers who are gnostics. Appearance of Gnosis (Sufism) in Islam Among the companions of the Prophet, Ali is known particularly for his eloquent exposition of gnostic truths and the stages of the spiritual life. His words in this domain comprise an inexhaustible treasury of wisdom.
Among the works of the other companions which have survived there is not a great deal of material that concerns this type of question. Among the associates of Ali, such as Salman Farsi, Uways Qarani, Kumayl ibn Ziyad, Roshaid Hajari, Maytham Tammar, Rabi'ibn Khaytham. However, there are figures who have been considered by the majority of the Sufis, Sunni and Shi'ite alike, as the heads of their spiritual chain (silsilah) after Ali.
After this group there appeared others, such as Tawus Yamani, Shayban Ra'i, Malik ibn Dinar, Ibrahim Adham, and Shaqiq Balkhi, who were considered by the people to be saints and men of God. These men, without publicly talking about gnosis and Sufism, appeared externally as ascetics and did not hide the fact that they had been initiated by the earlier group and had undergone spiritual training under them.
After them there appeared at the end of the 2nd/8th century and the beginning of the 3rd/9th century men such as Bayazid Bastami, Ma'ruf Karkhi, Junayd Baghdadi and others like them, who followed the Sufi path and openly declared their connection with Sufism and gnosis. They divulged certain esoteric sayings based on spiritual vision which, because of their repellent external form, brought upon them the condemnation of some of the jurists and theologians.
Some of them were imprisoned, flogged, and even occasionally killed. Even so, this group persisted and continued its activities despite its opponents. In this manner gnosis and the "Way" (Tariqah, or Sufism) continued to grow until in the 7th/13th and 8th/14th centuries it reached the height of its expansion and power. Since then, sometimes stronger and at other times less so, it has continued its existence to this very day within the Islamic world.
Gnosis or Sufism as we observe it today first appeared in the Sunni world and later among the Shi'ites. The first men who openly declared themselves to be Sufis and gnostics, and were recognized as spiritual masters of Sufi orders, apparently followed Sunnism in the branches (furu') of Islamic law.