The first "Zawiya al-Fassiya" was first established by Abdelkader's ancestor, Abu al-Mahasin (died in 1604), a Muslim scholar from Ksar el-Kebir and from a bourgeois family of Andalusi origin. Before coming to Fes, Abu al-Mahasin won some favour with the Saadian sultan Ahmad al-Mansur thanks to the warriors he sent to fight in the Battle of Ksar el-Kebir (also known as the Battle of the Three Kings) in 1578. He moved to Fes in 1580 and started a zawiya by teaching in his own house in the al-Mukhfiya neighbourhood (in the Andalusiyyin quarter of the city), which quickly developed into an important center of scholarship on its own. Abu al-Mahasin purchased neighbouring houses to accommodate its expansion and in 1596 converted one of the houses into a mosque for his zawiya, designating his son Abu al-Abbas Ahmad al-Hafiz as imam. The zawiya's teachings followed al-Jazuli's school of thought (itself within the Shadhili order) and those of Abd al-Rahman al-Majdub (died 1569), an earlier Sufi sheikh who spent time in Fes and who was Abu al-Mahasin's teacher.