Catalonia is an autonomous community of Spain, and designated a "nationality" by its Statute of Autonomy. Catalonia comprises four provinces: Barcelona, Girona, Lleida, and Tarragona. The capital and largest city is Barcelona, the second largest city in Spain, and the centre of one of the largest metropolitan areas in Europe, and it comprises most of the territory of the former Principality of Catalonia, with the remainder now part of France. Catalonia is bordered by France and Andorra to the north, the Mediterranean Sea to the east, and the Spanish regions of Aragon and the Valencian Community to west and south respectively. The official languages are Catalan, Spanish and Aranese (an Occitan dialect).
In the 10th century the eastern counties of the March of Gothia and the Marca Hispanica became independent from the Frankish kingdom, uniting as vassals of Barcelona. In 1137 Barcelona and Aragon formed the Crown of Aragon, and Catalonia became a maritime power and the main base for the Crown of Aragon's naval power and expansionism in the Mediterranean. Medieval Catalan literature flourished. Between 1469 and 1516, the King of Aragon and the Queen of Castille married and ruled their kingdoms together, retaining all their distinct institutions, courts, and the Constitution. During the Reapers' War (1640–52), Catalonia rebelled against the presence of the Castillian army in its territory, becoming a republic under French protection. Under the terms of the Treaty of the Pyrenees in 1659, which ended the wider Franco-Spanish war, Castille agreed with France to cede it the northern parts of Catalonia, mostly incorporated in the county of Roussillon. During the War of the Spanish Succession (1701–14), the Crown of Aragon sided against Philip V of Spain, whose subsequent victory led to the abolition of Catalan institutions, and the replacement of Latin or Catalan with the Spanish language in legal documents.
Despite the Napoleonic and Carlist Wars, Catalonia experienced economic growth and industrialisation. During the second half of the 19th century, the region saw a cultural renaissance coupled with incipient nationalism, while several workers movements appeared. In 1913, the four Catalan provinces formed a Commonwealth, and with the advent of democracy during the Second Spanish Republic (1931–39), the Generalitat of Catalonia, was restored. After the Spanish Civil War, the Francoist dictatorship enacted repressive measures, abolishing Catalan institutions and banning the official use of the Catalan language again. During the 1950s and 1960s, Catalonia saw significant economic growth and became an important tourist destination, drawing many workers from across Spain and making Barcelona one of Europe's largest industrial metropolitan areas. Since the Spanish transition to democracy (1975–82) Catalonia has recovered political and cultural autonomy and is now one of the most economically dynamic regions of Spain.