The Catalan counties (Catalan: Comtats Catalans, IPA: [kumˈtats kətəˈlans]) were those surviving counties of the Hispanic March and the southernmost part of the March of Gothia that were later united to form the Principality of Catalonia.
In 778, Charlemagne led the first military Frankish expedition into Hispania to create a military buffer zone between the Frankish Empire and the Emirate of Córdoba, occasionally known as the "Hispanic March". The territory that he subdued would in later centuries become the kernel of Catalonia (not yet known like that since the first written mention of Catalonia is in 1113). 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 Moors and to expand southwards into Muslim territory.