Tradition holds that Charles the Great (Charlemagne) granted a charter to Andorran people in return for fighting against the Moors. Overlordship of the territory passed to the local count of Urgell and eventually to the bishop of the diocese of Urgell. The Bishop then handed over the territory to the Lord of Caboet. The Caboet family married into the family of the French Count of Foix and through this marriage, the Count inherited all of the Spanish lord's land, including Andorra. In the eleventh century a dispute arose between the bishop and his northern neighbour over Andorra.
The conflict was resolved in 1278 by the signing of a paréage, which provided that Andorra's sovereignty be shared between the count of Foix (whose title would ultimately transfer to the French head of state) and the bishop of La Seu d'Urgell, in Catalonia, Spain. This gave the small principality its territory and political form.
Over the years the title passed to the kings of Navarre. After Henry of Navarre became King Henry IV of France, he issued an edict (1607) that established the head of the French state and the Bishop of Urgell as co-princes of Andorra.
In the period 1812–13, the First French Empire annexed Catalonia and divided it in four départements. Andorra was also annexed and made part of the district of Puigcerdà (département of Sègre).
Andorra declared war on Imperial Germany during World War I but did not actually take part in the fighting. It remained in an official state of belligerency until 1957 as it was not included in the Versailles Peace Treaty.
In 1933 France occupied Andorra as a result of social unrest before elections. On July 12, 1934, an adventurer named Boris Skossyreff issued a proclamation in Urgell, declaring himself Boris I, sovereign prince of Andorra, simultaneously declaring war on the bishop of Urgell. He was arrested by Spanish authorities on July 20 and ultimately expelled from Spain. From 1936 to 1940, a French detachment was garrisoned in Andorra to prevent influences of the Spanish Civil War and Franco's Spain. Francoist troops reached the Andorran border in the later stages of the war.
During World War II, Andorra remained neutral and was an important smuggling route between Vichy France and Spain.
Given its relative isolation, Andorra has existed outside the mainstream of European history, with few ties to countries other than France and Spain. In recent times, however, its thriving tourist industry along with developments in transportation and communications have removed the country from its isolation. Its political system was thoroughly modernized in 1993, the year in which it became a member of the United Nations and the Council of Europe.