Madrid is the capital of Spain and of Madrid Province , which is one of Spain's partially self-governing regions . city , capital of Spain and of Madrid provincia . Madrid is a city of contrasting styles . Madrid is a city of contrasting styles , reflecting clearly the different periods in which change and development took place . It has preserved its old , crowded center , with palaces , convents , churches , and public buildings dating to the early 17th century . Under the patronage of Philip and his successors , Madrid developed into a city of curious contrasts , preserving its old , overcrowded centre , around which developed palaces , convents , churches , and public buildings . Yet it is also Spain's largest , busiest city , an urban center of arts and industry . A national centre of arts and industry , the city and province form one of the new autonomous regions of the post-Franco era . Madrid is situated on the Meseta , a plateau in the center of Spain . It is situated on an undulating plateau of sand and clay known as the Meseta ( derived from the Spanish word mesa , or "table" ) at an altitude of 2,100 feet ( 635 metres ) above sea level , making it one of the highest capitals in Europe . Located at 2,100 feet ( 635 meters ) above sea level , Madrid is Europe's highest capital city . It is situated on an undulating plateau of sand and clay known as the Meseta ( derived from the Spanish word mesa , or "table" ) at an altitude of 2,100 feet ( 635 metres ) above sea level , making it one of the highest capitals in Europe . Madrid's old quarter is a maze of small streets and squares . The old centre , a maze of small streets around a few squares in the vicinity of the imposing Plaza Mayor , contrasts with the stately Neoclassical buildings and grand boulevards created by the most eminent architects of their day . Madrid has more than 40 parks and public gardens . There are , in fact , more than 40 parks and public gardens , the principal ones being the Retiro , Campo del Moro , Casa de Campo , and Oeste Park , not to mention the curious temple of Debod ( an ancient Egyptian temple acquired by Spain at the time of the construction of the Aswan High Dam ) near Rosales , with splendid panoramic views over the city . Once the site of a royal palace , the Retiro ( Retreat ) is now the city's largest park . Madrid's botanical gardens contain some 30,000 species of plants . Some , like El Pardo or Casa de Campo , are survivals of hunting parks; the Retiro , on the other hand , is the site of a former royal palace . The city's Museum of the Prado is one of the foremost art galleries in Europe . The most famous collection is housed in the Prado , which displays the artworks collected by the Spanish monarchy over the ages and reflects the pattern of Spain's alliances . Madrid is Spain's main center of higher education and includes several of the country's leading universities . Madrid is Spain's foremost centre of higher education and includes several of the country's leading universities , among which are the Open University ( Universidad Nacional de Educacion a Distancia ) , the Complutensian University , and the Polytechnical University , all in University City , and to the north the Autonomous University . Notable among Madrid's many libraries are the National Library and the Library of the Royal Palace . Notable among an abundance of libraries are the prestigious National Library ( Biblioteca Nacional ) and the Library of the Royal Palace , acclaimed for its historic collection . The capital city is an important center for the manufacturing of automobiles and aircraft . In the postwar period ( which , of course , for Spaniards means post-1939 -- since that was when the Spanish Civil War ended , and since Spain was neutral in World War II ) the city became an important manufacturing centre for the automotive and aircraft industries , and for electric and electronic equipment , and optics , the production of plastics and rubber , and consumer goods . It also produces electric and electronic equipment , optical instruments , plastics , and rubber . In the postwar period ( which , of course , for Spaniards means post-1939 -- since that was when the Spanish Civil War ended , and since Spain was neutral in World War II ) the city became an important manufacturing centre for the automotive and aircraft industries , and for electric and electronic equipment , and optics , the production of plastics and rubber , and consumer goods . Madrid is one of the major publishing centers for the Spanish-speaking world . Madrid , with Barcelona , dominates publishing in Spain . Madrid is one of the major publishing centers for the Spanish-speaking world . Madrid's literary traditions , its associations with Lope de Vega , Calderon , Cervantes , Quevedo , Perez Galdos , Larra , Baroja , and Azorin , continue in the city's varied cultural life , as demonstrated by the fact that it is one of the major publishing centres for the Spanish-speaking world . It is the country's center for banking and insurance , a major tourist site , and a transportation hub . Being the centre for government , finance , and insurance is a factor that has for long contributed to the prosperity of the capital , not to mention activities such as tourism and the city's position as the nation's transportation hub . It was then a town called Majerit that had grown around a castle . The Arab town , or medina , grew around the alcazar ( castle ) on a promontory overlooking the Manzanares River . The Christian king Alfonso VI of Castile and Leon captured the town in 1083 . The name Majerit first appears in AD 932 , when the Christian king Ramiro II of Leon razed the town's walls , but there are traces of earlier ( even prehistoric ) habitation . The Christian king Alfonso VI of Castile and Leon captured the town in 1083 . The Christian king Alfonso VI of Castile and Leon captured the town from the Muslims in 1083 , and thereafter a number of kings of Castile spent time there . In 1561 the Spanish king Philip II made Madrid the seat of his court . It was in 1607 , a whole generation after Philip II took the court to Madrid in 1561 , that Philip III officially made the city the national capital , a status it has retained ever since . In 1607 Philip III made the city Spain's permanent capital . It was in 1607 , a whole generation after Philip II took the court to Madrid in 1561 , that Philip III officially made the city the national capital , a status it has retained ever since . France occupied Madrid during the early 19th century . Madrid was occupied by French troops during the Napoleonic Wars , and Napoleon's brother Joseph was installed on the throne . On May 2 , 1808 , the city residents led a mass uprising against the French troops . On May 2 , 1808 , there was a mass uprising against Joseph , leading to what the Spaniards term "la Guerra de la Independencia." During the Spanish Civil War ( 1936-39 ) , Madrid suffered heavy bombing . The city suffered heavily in the Civil War , with two years of aerial and artillery bombardment and combat lines drawn up as close as University City .