 At this date, Cerdanya was united in government under one count with County of Besalú and Urgell; it was part of the 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.