The Moors conquered Barcelona in 717 and remained in power for just 80 years, and there are almost no Moorish remains. They established a garrison in the city under the command of a Wali. While the cathedral was converted into a mosque and taxes levied on non-Muslims, religious freedom and civil government was largely respected. The local Walí was mostly concerned with military matters, with the count and the local bishop having large day-to-day control of the local population. After a long siege, they lost the city to the Franks of Louis the Pious on 4th April 801.
Once the territory was under their control, the invaders took advantage of the main Visigoth administrative structures, both civil and ecclesiastic. Though they were not able to shape Barcelona along the model of an Islamic city, due to the short time they were here, they did establish a garrison under the orders of a Wali.
The Christians who did not flee the city formed the Mossarab community, in the same way that the Muslims who remained here became Mudejars when the Franks entered Barcelona.
The eighty years of Moorish rule ended on 4 April 801, with the arrival of Louis the Pious to the city.
By the end of the reign of Charlemagne, various muslim leaders who disagreed with the government in Cordoba had already had talks with the Franks to offer them the areas they controlled, in the Ebro basin and on the southern slopes of the Pyrenees. One was Wali Sa’dun, who, in 797, went to Aachen to ask for help against Cordoba, promising the surrender of Barcelona. In the end he changed his mind, but was unable to stop Barcelona from passing into the hands of the Franks.
Despite various unsuccessful attempts by the Emirat in Cordoba to recapture the city, the relationship between Barcelona and the Moors did not end there. Apart from the tragic expedition of al-Mansur (985), the Taifa kingdoms brought a major flow of Moorish gold to Barcelona that helped the subsequent prosperity, led by the. The Almoravids did not cease sending cavalry sorties against the city, more or less successful, until the beginning of the 12th century.