These two waves of immigrants would subsequently give their name to the sites 'Adwat Al-Andalus and 'Adwat al-Qarawiyyin.[4]:51 Both the Qarawiyyin Mosque and the Andalusiyyin Mosque are believed to have been founded around this period, in 859. The decline of the Idrisid dynasty afterward resulted in Fez changing hands between various empires and local factions in the 10th century.[5][3]