Madrid is the capital and most populous municipality of Spain. Madrid has almost 3.3 million inhabitants and a metropolitan area population of approximately 6.8 million. It is the second-largest city in the European Union (EU), and its metropolitan area is the second-largest in the EU. The municipality covers 604.3 km (233.3 sq mi) geographical area. Madrid lies on the River Manzanares in the central part of the Iberian Peninsula at about 650 m (2,130 ft) above mean sea level. The capital city of both Spain and the surrounding autonomous community of Madrid, it is the political, economic, and cultural centre of the country.
The primitive core of Madrid, a walled military outpost, dates back to the late 9th century, under the Emirate of Córdoba. Conquered by Christians in 1083 or 1085, it consolidated in the Late Middle Ages as a sizeable town of the Crown of Castile. The development of Madrid as an administrative centre was fostered after 1561, as it became the permanent seat of the court of the Hispanic Monarchy. The following centuries were characterised by the reinforcement of Madrid's status within the framework of a centralised form of state-building.