As Fez grew and the mosque increased in prestige, the original building was insufficient for its religious and institutional needs. During the 10th century, the Umayyad Caliphate of Córdoba and the Fatimid Caliphate constantly fought for control over Fez and Morocco, seen as a buffer zone between the two. Despite this uncertain period, the mosque received significant patronage and had its first expansions. The Zenata Berber emir Ahmed ibn Abi Said, one of the rulers of Fez during this period who was aligned with the Umayyads, wrote to the caliph Abd al-Rahman III in Córdoba for permission and funds to expand the mosque. The caliph approved, and the work was carried out or completed in 956. It expanded the mosque on three sides, encompassing the area of the present-day courtyard to the north and up to the current eastern and western boundaries of the building. It also replaced the original minaret with a new, larger minaret still standing today. Its overall form, with a square shaft, was indicative of the subsequent development of Maghrebi and Andalusian minarets.
