In 1111, the city was officially founded by the Count Roger II of Foix and the abbot of the of Saint Antonin of Pamiers; they built a castle (now demolished) and named it "Castrum Appamiae", after a Syrian city, Apamea, that was visited by Roger II during the First Crusade. A church was built at the foot of the castle (Our Lady of Mercadal) where is now the cathedral.