Abu al-Hasan ʿAli b. ʿAbd Allah al-Shadhili was born near Ceuta (Sabta) in northern Morocco in 592/1196. As a young man, Abu al-Hasan was famous for his learning and for his asceticism, which led him to undertake long periods in the wilderness engaged in worship and invocation. He studied in Fez, where he met a Sufi scholar, Muhammad b. Hirzihim (Harazim), whose influence on him was instrumental. In Iraq he met the Sufi master al-Wasiti, who told him he would find his true spiritual master in the Maghrib, where he had come from. On his return he met ʿAbd al-Salam Ibn Mashish (d. 625/1228), known as the Pole of the West, who had been a pupil of Abu Madyan. He was trained by pupils of Abu Madyan and became one of the most celebrated mystical teachers of his day.
Under Ibn Mashish's guidance, Abu al-Hasan underwent a thorough and rigorous training. At their initial meeting he asked his master about his inner spiritual condition, to which Ibn Mashish replied “I complain to God about the coolness of contentment and submission (bard al-riḍā wa al-taslīm), just as you complain to Him about the heat of self-direction and choice (ḥarr al-tadbīr wa al-ikhtiyār)”. When he saw Abu al-Hasan's astonishment at these words, he added “Because I fear that the sweetness of such an existence would make me neglectful of my duty towards God”.
He set up his first zawiya (Sufi lodge) in Tunis in 625/1228, where he had forty students, known as the forty friends (al-awliyā' al-arbaʿūn). He faced opposition from the establishment theologians in Tunisia, but following a dream-vision of the Prophet in 642/1244, he took up residence in Alexandria, Egypt. There his teachings attracted many students and followers, including many court officials and religious scholars. He founded a zawiya which created the distinctive devotional activities that would become part of the Shadhiliyya order. In 646/1248 he became blind, and participated in the Battle of Mansura, which prevented the Seventh Crusade from entering Egypt. Shortly before his last pilgrimage to Mecca, Baghdad fell to the Mongols, and as al-Shadhili made his way to Mecca with throngs of disciples, he fell ill and died in the eastern desert of Egypt, at Humaythara in 656/1258.
The formation of the Shadhiliyya tariqa (Sufi order) by his disciples led to the dissemination of his teachings throughout North Africa, and remains one of the four oldest Sufi tariqas. His prayers include the famous 'Litany of the Sea' (Ḥizb al-baḥr), and are still popular in many circles to this day.