Middle Ages · state
County of Barcelona
Frankish kings set up a frontier county against Muslim Spain at Barcelona, and its counts slowly turned it into Catalonia.
Muslim armies took north-eastern Spain in the early eighth century, and the Franks pushed them back. They took Girona in 785, and in 801 Louis the Pious, then king of Aquitaine, captured Barcelona and set up a county there on the southern frontier of the Carolingian Empire. The counties of the region slowly drifted from their Frankish overlords. Count Wilfred the Hairy, the last appointed by a Frankish king, gathered several of them under his rule and passed them to his sons, and Barcelona, Girona and Osona stayed together.
In 985 the Córdoban commander Almanzor attacked and burned Barcelona while Count Borrell II sheltered in the Montserrat mountains. No Frankish help came, and when the Carolingian dynasty ended in 988 there is no evidence that Borrell swore loyalty to the new king. Historians see this as the start of real independence. Ramon Berenguer I later tamed rebellious nobles, took tribute from the Muslim kingdoms of Zaragoza and Lleida and introduced the Usages of Barcelona, the base of later Catalan law.
Ramon Berenguer III gained Besalú and Cerdanya, and through his marriage to Countess Dolça in 1112, Provence. In 1137 his son Ramon Berenguer IV was promised in marriage to Petronilla, heiress of Aragon. In 1162 their son Alfonso II became both King of Aragon and Count of Barcelona.
Read more on Wikipedia
Sources: en.wikipedia.org/wiki/County of Barcelona, en.wikipedia.org/wiki/Girona

