The County of Cerdanya (Catalan: Comtat de Cerdanya, IPA: [kumˈtad də sərˈð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.