Captured by Louis the Pious in 801, Barcelona became the key city in the Marca Hispánica, a buffer zone created by the Carolingian Empire between Christian and Muslim territories. Counts appointed by the Franks governed the city, but over the 9th and 10th centuries, local leaders like Wilfred the Hairy began to assert hereditary control, laying the foundations of Catalan autonomy. Though still nominally loyal to the emperor, Barcelona increasingly acted as an independent power during this formative period.