In 785, 'Abd al-Rahman I (reg 756-788) built a mosque with eleven aisles and twelve bays over an early eighth-century mosque. The mosque was enlarged in the ninth century, but the most extensive work was completed under al-Hakam II (reg 961-976) from 961-966 and al-Mansur (d 1002) from 987-988.