In 711, Muslim forces invaded and conquered most of the Iberian Peninsula except a small part of northern Spain, establishing Al-Andalus. For over 700 years, Muslims and Christians fought for control of the region. By the end of the Middle Ages, Christian forces had grown stronger and began to reconquer the territory. Under Abd al-Rahman III in 756, the Umayyad dynasty established the Caliphate of Córdoba, a Muslim kingdom ruled by a caliph. Society in Al-Andalus was divided into Muslims, Christians, and Jews, with people living in walled towns and cities containing markets, mosques, and fortified palaces.