The County of Cerdanya (Catalan: Comtat de Cerdanya, IPA: [kum'tad d? s'ða]; Latin: Comitatus Ceritaniae; Spanish: Condado de Cerdaña, French: Comté de Cerdagne) was one of the Catalan counties formed in the last decades of the 8th century by the Franks in the Marca Hispanica. The original Cerdanya consisted of the valley of the upper Segre. Today Cerdanya is a Catalan comarca.
The region had been conquered by the Moors in the early 8th century. In 731, the Moorish governor of Cerdanya allied himself with Odo the Great by marrying his daughter, at Odo's insistence, in order to secure his southern frontier from further Muslim expansion. Cerdanya was at this time predominantly Basque, and Odo had a pro-Basque policy in the face of Charles Martel and the Franks.
Moorish rule was soon purely nominal; the Cerdanya was conquered by Charlemagne shortly after the surrender of Girona in 785. The first Count of Cerdanya that we know of by name was Borrell I (798), who was subject to the Count of Toulouse. At this date, Cerdanya was united in government under one count with County of Besalú and Urgell; it was part of the Kingdom of Aquitaine after 817. Cerdanya and Urgell remained united until 897 and both were under the influence and often control of the Count of Aragon. In 842, the Emirate of Córdoba invaded Cerdanya in an attempt to regain the Pyrenees, but they were repulsed by Count Sunifred.
In the 9th century, Cerdanya was the centre of a region wherein the aprisio form of landholding was common. In 835, a charter of Louis the Pious even forbid the church of the region to grant lands in beneficium, that is, as benefices or in feudal tenure.
After the death of Louis the Stammerer (879), Aquitaine and West Francia in general experienced a period of instability during which the outlying regions, such as Catalonia, became de facto independent of central royal authority. During this period as well, the office of count became de facto hereditary.
The 10th century saw repeated divisions and reunions of the familial lands of the Bellonids and Cerdanya was repeatedly attached to and detached from its neighbouring regions and counties. The counts of Cerdanya frequently used the title marchio, meaning margrave, during this period. This was an indication of their status as frontier lords and of the breakdown in royal authority, which permitted regional magnates to assume whatever titles they wished without incurring royal disfavour. As another result of its frontier location and the lack of royal control exercised over it, Cerdanya was dotted with numerous castles during this period, when the Muslim threat was still strong.
In 897, Wilfred the Hairy died having divided his vast Catalan patrimony (technically just a plurality of public offices) between his four sons. Cerdanya, Conflent, and Berga went to Miro. The Fenouillèdes and Capcir were also annexed to Cerdanya at this time. From 913 to 920, Miro also held Besalú, but on his death in 927, his territories were divided between his four sons. The eldest, Sunifred, received Cerdanya and a certain primacy over his brothers. In the last half of the 10th century, the counties of Miro were reunited (984) under one ruler: Oliba Cabreta.
His county comprised Besalú, the Fenouillèdes, Capcir, the Baridà, the valley of Orillas, that of Lillet, the Berguedà, the Ripollés, the Vallespir, the upper plain of Roussillon from Illa de Tet to Sant Esteve del Monasterio, Conflent, the Donasà, and Peyrepertuse. Oliba's counties and the counties of Borrell II, Count of Barcelona, formed the two main divisions of Catalonia during the latter half of the 10th century. Oliba brought Cerdanya to its zenith. He expanded his lordship to the north into the County of Carcassonne and to the west into the Counties of Roussillon and Empúries. He extended his authority over the churches of Sant Joan de les Abadesses and Lagrasse and usurped the de facto supremacy in Catalonia from Borrell II of Barcelona. In 988, Oliba Cabreta retired to the monastery of Montecassino and divided his lands between his three sons, the second-born, Wilfred, receiving Cerdanya and Conflent. In 1002, Berga was annexed to Cerdanya.
It is clear, however, from evidence dating from between 987 and 1031, that the Carolingian court system and Visigothic law were still in effect in Cerdanya. The count presided over judicial tribunals with the assistance of the judices (judges) and boni homines (good men) of the county.
During the 11th century, Cerdanya became increasingly feudalised and drawn into the orb of Toulouse and Foix. The counts of Toulouse desired to control the pass of Pimorent (French: Puymorens) in Cerdanya, and those of Foix desired some control of the frontier with Moorish Lérida. The counts of Cerdanya, for their part, were interested in furthering their control of the church in the Midi and Catalonia; they had already controlled the important monasteries of Sant Miquel de Cuixà and Ripoll since the early 10th century. In 1016, they purchased the right to the archbishopric of Narbonne for 100,000 solidi for their relative Guifred and, not long after, that to the bishopric of Urgell as well. The famous Abbot Oliva was a member of the ruling dynasty of Cerdanya. When Count Raymond Wilfred plundered the Sant Miquel de Cuixà and entered into a feud with the Bishop of Elne, it gave the nobles opportunity to grant their services to whoever offered them the most advantage at the moment.
In this period of political confusion, the viscount Bernard Sunifred rebelled. His lands were clustered in the north of Cerdanya, in the Segre valley and Conflent with their centre at Merencs. He put his lands under the nominal suzerainty of the count of Toulouse and tried to draw them away from Cerdanya. Bernard was forced to make peace with Raymond in 1047 and his allodial lands were handed over, though he was compensated with more fiefdoms from the count. Bernard rebelled a second time and was forced to make peace again in 1061. The important pass of Pimorent, which, now that Cerdanya was no longer a marcher territory, lay at the centre of its existence, remained in the hands of the Count Raymond and neither of Bernard's allies of Toulouse or Foix.
The viscounts of Cerdanya and the others regions, like Conflent and Fenouillèdes, were the main antagonists of the comital power in Cerdanya throughout the 11th century. Briefly, William Raymond had to fight a war (successfully) with Giselbert II of Roussillon over the possession of the monastery of Cuixà, which Cerdanya had controlled throughout the 10th century, but in the main, the viscounts were the greatest military detriment to the counts of Cerdanya. Between 1088 and 1092, William founded Vilafranca de Conflent. William's successor, William Jordan, joined the First Crusade, and in his absence, the counts' authority was weakened still further. In 1118, Cerdanya was sold to Barcelona and only occasionally bestowed thereafter as appanage for younger sons.
The failure of the county of Cerdanya to establish lasting supremacy over Catalonia lies in the penchant of its counts to divide their patrimony between all of their sons — and the rights of inheritance of brothers — and the gathering strength of the nobility following the decline of Cerdanya's military importance. In 1058, when Count Raymond accepted the pay of Raymond Berengar I of Barcelona to be his ally in the fight against the Moors, the fate of Cerdanya to be in the control of Barcelona was sealed. In the next centuries, Cerdanya was part of the Principality of Catalonia.
The title then passed finally and permanently to the Crown of Aragon.