Catalan counties
The Catalan counties (, ) were the administrative Christian divisions of the eastern Carolingian "Hispanic Marches" and the southernmost part of the March of Gothia in the Pyrenees created after their rapid conquest by the Franks. The various counties roughly defined what later came to be known as the Principality of Catalonia. In 778, Charlemagne led the first military Frankish expedition into Hispania to create the "Hispanic Marches", a buffer zone between the Umayyad Moors and Arabs of Al-Andalus and the Frankish Kingdom of Aquitaine. The territory that he subdued was the kernel of Catalonia (not yet known like  that since the first written mention of Catalonia and the Catalans as an ethnicity appears almost a century later in 1113 at the Liber maiolichinus) which was already a no man's land since the defeat of the visigoths and the arrival of the Muslims in 714 who crossed the Pyrenees with an army to be defeated in 732 at the Battle of Tours. In 781, Charlemagne made his 3-year-old son Louis the Pious (778 – 840) king of Aquitaine, who was sent there with regents and a court in order to secure the southern border of his kingdom  against the Arabs and the moors and to expand southwards into Muslim territory. These counties were originally feudal entities ruled by a small military elite. Counts were appointed directly by and owed allegiance to the Carolingian (Frankish) emperor. The appointment to heirs could not be taken for granted. However, with the rise of the importance of the Bellonids and strong figures among them such as, Sunifred (fl. 844–848) and Wilfred the Hairy (c.870-897), and the weakening of Carolingian royal power, the appointment of heirs eventually become a formality. This trend resulted in the counts becoming "de facto" independent of  the Carolingian crown under Borrell II in 987, starting since, to call themselves and to be known as "dei gratia comes" (counts by the grace of god) and "dux catalanensis" (Catalan dukes) or even "Hispaniae subjogator" (attorney of Hispania) and "Propugnator et murus christiani populi" (wall and defender of the Christian folk). The many counties (aside from the counties of County of Pallars, County of Urgell and County of Empuries) were to be soon absorbed into the County of Barcelona and one of his counts, prince Ramon Berenguer IV, count of Barcelona married princess Petronilla of Aragon of the Kingdom  of Aragon in 1150, uniting as equals the County of Barcelona and the Kingdom of Aragon. Thus, their son became the first king of the Crown of Aragon, ruling over both the Catalans and the Aragonese. Creation. The reconquista from the Moors by the Franks began in 785. In 785, Rostany (or Rostaing) was made Count of Girona, the first of the Catalan counties to be established. Besalú and Empúries were originally part of Girona. In 801, in the greatest military triumph of his long career, the young Louis took Barcelona, the greatest city of the Catalan littoral. When Urgell  and Cerdanya were subdued around 798, they were also made counties and Borrell was made count. He took a very active part in the subsequent conquest of Osona in 799 and the successful siege of Barcelona in 801. He was made count of Osona in 799, perhaps as a reward for his services. In 801, the greatest of the counties, Barcelona, was established under Bera. In 812, Count Odilo of Girona (which included Besalú and Empúries) died and the county also passed to Bera. In 804 and 805, Borrell participated in the expeditions to Tortosa, but not in the subsequent  campaigns of 808 and 809. On Borrell's death in 820, Osona was given to Rampon and Urgell and Cerdanya went to Aznar Galíndez. Also in 820, Bera went into political disfavour and lost the countships of Barcelona and Girona, which also went to Rampon. Around 813, Empúries became a separate county under Ermenguer, and in 817, it was united to the County of Roussillon. From 835 to 844, Sunyer I was count of Empúries and Peralada while Alaric I was count of Roussillon and Vallespir. Besalú was made a separate county in 878 for Radulf on the condition that  it pass to the heirs of Wilfred the Hairy on his death. It went to Miro I the Younger in 912. Barcelona soon overshadowed the other counties in importance, especially during the reign of Wilfred the Hairy in the late 9th century. At that time, the power of the Carolingians was waning and the neglected Hispanic march was practically independent of royal authority. In the early 11th century, Berenguer Ramon I, Count of Barcelona, was able to submit to Sancho III of Navarre as his suzerain, even though he was still legally a vassal of Robert II of France. With  the accession of Robert's father, Hugh Capet, the first non-Carolingian king, in 987, most of the Catalan counts refused to pay homage to the new dynasty. Over the next century, most of the Catalan counties came into the hands of the counts of Barcelona. In time, one of the Counts of Barcelona, Ramon Berenguer IV, married the heiress of Aragon, Petronella, uniting the counties under the count's power to that kingdom, creating the Crown of Aragon. Several of the later kings re-created some Catalan counties as appanages for younger sons.