The medieval town of Perpignan seems to have been founded around the beginning of the 10th century (first mentioned in a document as "villa Perpinianum" in 927). Soon Perpignan became the capital of the County of Roussillon. The last Count of Rossillon, Girard II, gave his lands in 1172 to the King of Aragón and Count of Barcelona.