incursions of Musa ibn Nusayr and becoming more definitive with the advent of the Idrisid dynasty at the end of that century. The arrival of Islam was extremely significant as it developed a new set of societal norms (although some of them were familiar to Judeo-Christian societies) and institutions which therefore shaped, to some extent, the types of buildings being built and the aesthetic or spiritual values that guided their design. The Idrisids founded the city of Fes, which became their capital and the major political and cultural center of early Islamic Morocco. In this early period Morocco also absorbed waves of immigrants from Tunisia and al-Andalus (Muslim-ruled Spain and Portugal), who brought in cultural and artistic influences from their home countries. The earliest well-known Islamic-era monuments in Morocco, such as the al-Qarawiyyin and Andalusiyyin mosques in Fes, were built in the hypostyle form and made early use of the horseshoe or "Moorish" arch. These reflected early influences from major monuments like the Great Mosque of Kairouan and the Great Mosque of Cordoba. In the 10th century much of northern Morocco came directly within the sphere of influence of the Umayyad Caliphate of Cordoba, with competition from the Fatimid Caliphate further east. Early contributions to Moroccan architecture from this period include expansions to the Qarawiyyin and Andalusiyyin mosques and the addition of their square-shafted minarets, the oldest surviving mosques in Morocco, which anticipate the standard form of later Moroccan minarets. The Berber Empires: Almoravids and Almohads (11th–13th centuries) The collapse of the Cordoban caliphate in the early 11th century was followed by the significant advance of Christian kingdoms into Muslim al-Andalus and the rise of major Berber empires in Morocco. The latter included first the Almoravids (11th-12th centuries) and then the Almohads (12th-13th centuries), both of whom also took control of remaining Muslim territory in al-Andalus, creating empires that stretched across large parts of western and northern Africa and into Europe. This period is considered one of the most formative stages of Moroccan and Moorish architecture, establishing many of the forms and motifs that were refined in subsequent centuries. These two empires were responsible for establishing a new imperial capital at Marrakesh and the Almohads also began construction of a monumental capital in Rabat. The Almoravids adopted the architectural developments of al-Andalus, such as the complex interlacing arches of the Great Mosque in Cordoba and of the Aljaferia palace in