Andorra's freedom is traditionally assigned to Charlemagne, who recovered the region from the Muslims in AD 803, and to his son Louis I the Pious, who granted the inhabitants a charter of liberties. Charlemagne's grandson, Charles II, granted Andorra to the counts of Urgel, from whom it passed to the bishops of Urgel. Andorra's seven-century-old dual allegiance to two princes, one in Spain and one in France, originated in the late 13th century in a proprietary quarrel between the Spanish bishops of Urgel and the French heirs to the countship of Urgel. The coprincipality has traditionally had a strong kinship with the region of Catalonia in northern Spain. Andorra's official language is Catalan; its institutions are based in Catalonian law, and a large proportion of the Spanish immigrants in Andorra are Catalan. Most Andorrans are Roman Catholic, and the principality is part of the diocese of the See of Urgel. Nearly two-thirds of the population is urban.
Andorra consists of a cluster of mountain valleys whose streams unite to form the Valira River. With only about 3 % of the land cultivable, the traditional economy centred on the pasturing of sheep and the harvesting of modest quantities of tobacco, wheat, olives, grapes, and potatoes. Industry was limited to processing these products and to handicrafts. From the 1950s tourism became one of Andorra's chief industries, exploiting the scenic attractions of the mountains and the area's excellent opportunities for winter sports. Because of the deficiency of customs duties and low or nonexistent taxes, Andorra in the late 20th century also became an valuable international centre of retail trade that attracted millions of shoppers from all over Europe with its duty-free imported consumer goods.