People settled this valley before the Christian era, and the Andosin tribe was here from the late Neolithic. In the eighth century Charlemagne set up a string of Catalan counties as a buffer against the Moors in Iberia, and Andorra belonged to Urgell.
In 1278 two co-princes, one French and one a bishop, agreed to rule Andorra jointly, and the town became its main settlement. That deal kept a small, isolated feudal lordship alive for centuries. The Barri Antic still has streets and buildings from the period, and the church of Sant Esteve belongs to that old core.
The Casa de la Vall went up in the early sixteenth century. It has housed the state's parliament since 1702, and you can still tour it. The modern Consell General building stands close by.
For a long time the place was forgotten. Well into the twentieth century the area stayed quiet, until political turmoil in the 1930s and a failed coup attempt by Boris Skossyreff. An informal democracy grew afterwards, and the first constitution made it formal in 1993, with all three branches of government based in the capital.
Most of the modern city is recent. It was built up in the twentieth century, as ski resorts opened around it and tourism took off. Since 1993 the country has also worked as a tax haven, which explains the banking offices. The capital bid for the 2010 Winter Olympics but the IOC did not pick it as a candidate, and it has hosted the Games of the Small States of Europe twice, in 1991 and 2005.