Under Almoravid patronage the largest expansion and renovation of the Great Mosque of Kairouan took place (1134-1143).Although the capital was moved to Marrakesh and Tlemcen under the Almoravids, Fez acquired a reputation for Maliki legal scholarship and became an important centre of trade.The migration of 2000 Arab families in the early 9th century gave the nascent city its Arabic character.After the downfall of the Idrisid dynasty, several empires came and went until the 11th century when the Almoravid Sultan Yusuf ibn Tashfin united the two settlements and rebuilt the city, which became today's Fes el Bali quarter.Under the Almoravid rule, the city gained the reputation for the religious scholarship and the mercantile activity.Fez was expanded during the Almohad rule and became the largest city in the world during 1170-1180 with the estimated population of 200,000.
It consisted of two autonomous and competing settlements.
Arab emigration to Fez, including 800 Andalusi families of Berber descent in 817–818 expelled after a rebellion against the Umayyads of Córdoba, Andalusia, and 2000 Arab families banned from Kairouan (modern Tunisia) after another rebellion in 824, gave the city its Arabic character.
The Andalusians settled in what is called the 'Old' Fez, while the Tunisians found their home in the 'New' Fez, also called al-'Aliya.
Located to the northeast of Atlas Mountains, Fez is situated at the crossroad of the important cities of all regions; 206 km (128 mi) from Tangier to the northwest, 246 km (153 mi) from Casablanca, 169 km (105 mi) from Rabat to the west, and 387 km (240 mi) from Marrakesh to the southwest which leads to the Trans-Saharan trade route.
It is surrounded by the high grounds, and the old city is penetrated by the River of Fez flowing from the west to east.