Llívia is a town of Cerdanya, province of Gerona, Catalonia, Spain, that forms a Spanish exclave surrounded by French territory (Pyrénées-Orientales département). In 2007, the municipality of Llivia had a total population of 1,388.
Llivia is separated from the rest of Spain by a corridor about 2 km (1.2 mi) wide, which includes the French communes of Ur and Bourg-Madame.
Llívia was the site of an Iberian oppidum which commanded the region and was named Julia Libica by the Romans. It was the ancient capital of Cerdanya in antiquity, before being replaced by Hix (commune of Bourg-Madame, France) in the Middle Ages. During the Visigothic period, its citadel, the castrum Libiae, was held by the rebel Paul of Narbonne against king Wamba in 672.
In 1659, the Treaty of the Pyrenees ceded the comarques of Roussillon, Conflent, Capcir, Vallespir, and northern Cerdanya ("Cerdagne") to the French crown. Llívia did not become part of the French kingdom as the treaty stipulated that only villages were to be ceded to France, and Llívia was considered a city and not a village due to its status as the ancient capital of Cerdanya.
In 1939, at the end of the Spanish Civil War, there was some discussion of Llívia remaining a free territory of the defeated Republican government, but this was never carried out.
Every second complete week in July, classes about traditional and popular festivities and festivals in Catalonia, and different performances by leading artists. Official website