To begin with we would need to mention the famous incident that took place at Ghadeer Khumm, in which Prophet Muhammad ﷺ brought Hazrat Ali (a.s) closer to him, in front of a large Muslim gathering and said: “Anyone whose Mawla (protecting friend/spiritual guide) I am, Ali is his Mawla (protecting friend/spiritual guide).” Shahwaliullah Dehlavi and Imam Ahmad Sirhindi, 2 renown figures of Islam from Mughal Era India have given an interesting explanation of this narration by mentioning that there are 2 types of leadership or caliphate in Islam, and how did they succeed the blessed Prophet ﷺ.
There are 2 types of Khilafat (Caliphate) - Apparent and Hidden
Shah Waliullah Muhaddith Dehlavi said that two types of leadership appeared after the Prophet; one was the ‘apparent leadership’ (khilafate zahiri) also called the political leadership and the other ‘hidden leadership’ (khilafate baatini) also referred to as wilaya (spiritual sovereignty and leadership). The first Prophet's successor and Caliph Hazrat Abu Bakr inherited the ‘apparent leadership’ (khilafate zahiri), established with the consensus of the companions and majority Muslims, and is categorically proved by the evidence of history and its blessings filtered down to the righteous and just rulers. This is the political office of the religion of Islam, established for improving the administration of the earth.
Shah Waliullah then said that the second type of leadership that emanated from Prophet Muhammad ﷺ was the spiritual legacy of ‘internal sovereignty’ or khilaafate baatini. This spiritual legacy of the Prophet also called wilaya (spiritual sovereignty and leadership) is exclusively a spiritual office, being not an elective and consultative issue but a selective act, selected by Allah ﷻ. The declaration of the first Imam of spiritual sovereignty was done by the Prophet ﷺ at Ghadir Khumm (Pond) of Khumm and Hazrat Ali (r.a) was selected for that honor.
This spiritual leadership that Ali Ibn Abi Talib (a.s) was honored with was to further descend down his chosen ones among his and Fatima (r.a) descendants through their beloved sons Imam Hassan (r.a) and Imam Hussain (r.a). If one notices that majority of the saints that have lived either in the South Asian and Central Asian parts of the Muslim world or North Africa and Middle East were usually descendants from these 2 Imams. This can also be realized when one understands 2 traditions of the Prophet ﷺ in the light of the above explanation when he said “I am leaving two things in your midst if you hold fast to it you will not go astray. They are The Book of Allah and my Sunnah (way & words)" and the next one was "I am leaving two important things in your midst which exceed each other in importance: One (is) Allah’s Book and the other (is) my progeny." The Prophet ﷺ connected the path of guidance to his progeny and descendants who have been given this great burden of carrying over their shoulders of guiding others through knowledge of Allah’s book and Prophetic Sunnah. Many of his descendants did precisely what was predicted by the Prophet ﷺ in the tradition and were able to spread the fragrance of spiritual status that Ali (r.a) received from the Prophet Muhammad ﷺ at the point of Ghadir Khumm.
However one thing to keep in mind is that the way of Ali ibn Abi Talib (a.s) was not only inherited by his descendants but were also inherited by those who were not his descendants. Such as Maruk Karkhi (r.a) received spiritual guidance from Imam Ali Rida (r.a), a descendant of Imam Hussain (r.a) but then became a great saint in his own right. Imam Sirhindi of Mughal era was a great saint and so was Sahl Tustari (r.a), Mawlana Rumi (r.a) and Junayd Baghdadi (r.a) were all great saints of their times and in their own right, were not descended from Ali (r.a) but became great only due to following the path of Imam Ali (r.a), whose life was the embodiment and prime example of Jihad e Nafs (struggle against one's evil self). Thus we notice that majority of Sufi tariqahs (paths) are all inheriting their spiritual way of life from Ali (a.s). Hence comparing the life of Imam Ali (r.a) to the lives of the Sufi saints that have lived throughout the Islamic history, one can notice that they were closer to his path than any one else.