History of Madrid

The documented history of Madrid dates to the 9th century, even though the area has been inhabited since the Stone Age. The primitive nucleus of Madrid, a walled military outpost in the left bank of the Manzanares, dates back to the second half of the 9th century, during the rule of the Emirate of Córdoba. Conquered by Christians in 1083 or 1085, Madrid consolidated in the Late Middle Ages as a middle to upper-middle rank town of the Crown of Castile. The development of Madrid as administrative centre began when the court of the Hispanic Monarchy was settled in the town in 1561.

Fortress and town


The primitive urban nucleus of Madrid (Majriṭ) was founded in the late 9th century (from 852 to 886) as a citadel erected on behalf of Muhammad I, the Cordobese emir, on the relatively steep left bank of the Manzanares. Originally it was largely a military outpost for the quartering of troops. Similarly to other fortresses north of the Tagus, Madrid made it difficult to muster reinforcements from the Asturian kingdom to the unruly inhabitants of Toledo, prone to rebellion against the Umayyad rule. Extending across roughly 8 ha, Muslim Madrid consisted of the alcázar and the wider walled citadel (al-Mudayna) with the addition of some housing outside the walls. By the late 10th century, Majriṭ was an important borderland military stronghold territory with great strategic value, owing to its proximity to Toledo. The most generous estimates for the 10th century tentatively and intuitively put the number of inhabitants of the 9 ha settlement at 2,000. The model of repopulation is likely to have been by the Limitanei, characteristic of the borderlands.

The settlement is mentioned in the work of the 10th-century Cordobese chronicler Ahmad ibn Muhammad al-Razi, with the latter locating the Castle of Madrid within the district of Guadalajara. After the Christian conquest, in the first half of the 12th century Al-Idrisi described Madrid as a "small city and solid fortress, well populated. In the age of Islam, it had a small mosque where the khuṭbah was always delivered," and placed it in the province of the sierra, "al-Sārrāt". It was ascribed by most post-Christian conquest Muslim commentators, including Ibn Sa'id al-Maghribi, to Toledo. This may tentatively suggest that the settlement, part of the cora of Guadalajara according to al-Razi, could have been transferred to Toledo following the Fitna of al-Andalus. The city passed to Christian control in the context of the conquest of Toledo; historiography debates whether if the event took place in 1083, before the conquest of Toledo, in the wake of negotiations between Alfonso VI and al-Qadir, or afterwards, as a direct consequence of the seizure of Toledo in 1085.

The mosque was reconsecrated as the church of the Virgin of Almudena (almudin, the garrison's granary). The society in the 11th and 12th centuries was structured around knight-villeins as a leading class in the local public, social and economic life. The town had a Muslim and mozarabic preexisting population (a number of the former would remain in the town after the conquest while the later community would remain very large throughout the high middle ages before merging with the new settlers). The town was further repopulated by settlers with a dominant Castilian-Leonese extraction. Frank settlers were a minority but influential community. The Jewish community was probably smaller in number than the mudéjar one, standing out as physicians up until their expulsion. By the end of the middle ages, the best-positioned members of the mudéjar community were the alarifes ('master builders'), who were tasked with public works (including the management of the viajes de agua), and had a leading role in the urbanism of the town in the 15th century.

Since the mid-13th century and up to the late 14th century, the concejo of Madrid vied for the control of the Real de Manzanares territory against the concejo of Segovia, a powerful town north of the Sierra de Guadarrama mountain range, characterised by its repopulating prowess and its husbandry-based economy, contrasted by the agricultural and less competent in repopulation town of Madrid. After the decline of Sepúlveda, another concejo north of the mountain range, Segovia had become a major actor south of the Guadarrama mountains, expanding across the Lozoya and Manzanares rivers to the north of Madrid and along the Guadarrama river course to its west.

The society of Madrid before the 15th century was an agriculture-based one (prevailing over livestock), featuring a noteworthy number of irrigated crops. Two important industries were those of the manufacturing of building materials and leather.

John I of Castile gifted Leo V of Armenia the lordship of Madrid together with those of Villa Real and Andújar in 1383. The Madrilenian concejo made sure that the privilege of lordship did not become hereditary, also presumably receiving a non-sale privilege guaranteeing never again to be handed over by the Crown to a lord.

Later, Henry III of Castile (1379–1406) rebuilt the town after it was destroyed by fire, and he founded El Pardo just outside its walls.

During the 15th century, the town became one of the preferred locations of the monarchs of the Trastámara dynasty, namely John II of Castile and Henry IV of Castile (Madrid was the town in which the latter spent more time and eventually died). Among the appeals the town offered, aside from the abundant game in the surroundings, the strategic location and the closed link between the existing religious sites and the monarchy, the imposing alcázar frequently provided a safe for the Royal Treasure. The town briefly hosted a medieval mint, manufacturing coins from 1467 to 1471. Madrid would also become a frequent seat of the court during the reign of the Catholic Monarchs, spending reportedly more than 1000 days in the town, including a 8-month long uninterrupted spell. By the end of the Middle Ages, Madrid was placed as middle to upper-middle rank town of the Castilian urban network in terms of population. The town also enjoyed a vote at the Cortes of Castile (one out of 18) and housed many hermitages and hospitals.

Facing the 1492 decree of expulsion, few local Jews opted for leaving, with most preferring to convert instead, remaining as a non-fully assimilated converso community, subject to rejection by Old Christians. Likewise, adoption of Christianism by the mudéjar community facing the 1502 pragmatic law of forced conversion was also widespread. Seeking to protect its economic interests, the council actively promoted assimilation in the latter case by awarding tax and economic benefits, and gifts.

The 1520–21 Revolt of the Comuneros succeeded in Madrid, as, following contacts with the neighbouring city of Toledo, the comunero rebels deposed the corregidor, named Antonio de Astudillo, by 17 June 1520. Juan Zapata and Pedro de Montemayor found themselves among the most uncompromising supporters of the comunero cause in Madrid, with the former becoming the captain of the local militias while the later was captured by royalists and executed by late 1520. The end of revolt came through a negotiation, though, and another two of the leading figures of the uprising (the Bachelor Castillo and Juan Negrete) went unpunished.

Capital of the empire
Philip II (1527–1598), moved the court to Madrid in 1561. Although he made no official declaration, the seat of the court became the de facto capital. Unlikely to have more than 20,000 inhabitants by the time, the city grew approaching the 100,000 mark by the end of the 16th century. The population plummeted (reportedly reduced to a half) during the 5-year period the capital was set in Valladolid (1601–1606), with estimations of roughly 50–60,000 people leaving the city. The move (often framed in modern usage as a case of real estate speculation) was promoted by the valido of Philip III, Duke of Lerma, who had previously acquired many properties in Valladolid. Madrid undertook a mammoth cultural and economic crisis and the decimation of the price of housing ensued. Lerma acquired then cheap real estate in Madrid, and suggested the King to move back the capital to Madrid. The king finally accepted the additional ducats offered by the town of Madrid in order to help financing the move of the royal court back to Madrid.

During the 17th century, Madrid had a estate-based society. The nobility, a quantitatively large group, swarmed around the royal court. The ecclesial hierarchy, featuring a nobiliary extraction, shared with the nobility the echelon of the Madrilenian society. The lower clergy, featuring a humble extraction, usually had a rural background, although clerics regular often required certifications of limpieza de sangre if not hidalguía. There were plenty of civil servants, who enjoyed considerable social prestige. There was a comparatively small number of craftsmen, traders and goldsmiths. Domestic staff was also common with servants such as pages, squires, butlers and also slaves (owned as symbol of social status). And lastly at the lowest end, there were homeless people, unemployed immigrants, and discharged soldiers and deserters.

During the 17th century, Madrid grew rapidly. The royal court attracted many of Spain's leading artists and writers to Madrid, including Cervantes, Lope de Vega, and Velázquez during the so-called cultural Siglo de Oro. By the early 1800s, Madrid hosted a slave population, tentatively estimated to range from 6,000 to 15,000 out of total population larger than 150,000. Unlike the case of other Spanish cities, during the 18th century the slave population in Madrid was unbalanced in favour of males over females.

In 1739 Philip V began constructing new palaces, including the Palacio Real de Madrid. Under Charles III (1716–1788) that Madrid became a truly modern city. Charles III, who cleaned up the city and its government, became one of the most popular kings to rule Madrid, and the saying "the best mayor, the king" became widespread. Besides completing the Palacio Real, Charles III is responsible for many of Madrid's finest buildings and monuments, including the Prado and the Puerta de Alcalá.

Amid one of the worst subsistence crises of the Borbón monarchy, the installation of news lanterns for the developing street lighting system—part of the new modernization policies of the Marquis of Esquilache, the new Sicilian minister—led to an increase on oil prices. This added to an increasing tax burden imposed on a populace already at the brink of famine. In this context, following the enforcing of a ban of the traditional Spanish dress (long cape and a wide-brimmed hat) in order to facilitate the identification of criminal suspects, massive riots erupted in March 1766 in Madrid, the so-called "Mutiny of Esquilache".

During the second half of the 18th century, the increasing number of carriages brought a collateral increment of pedestrian accidents, forcing the authorities to take measures against traffic, limiting the number of animals per carriage (in order to reduce speed) and eventually decreeing the full ban of carriages in the city (1787).

On 27 October 1807, Charles IV and Napoleon signed the Treaty of Fontainebleau, which allowed French troops passage through Spanish territory to join Spanish troops and invade Portugal, which had refused to obey the order for an international blockade against England. In February 1808, Napoleon used the excuse that the blockade against England was not being respected at Portuguese ports to send a powerful army under his brother-in-law, General Joachim Murat. Contrary to the treaty, French troops entered via Catalonia, occupying the plazas along the way. Thus, throughout February and March 1808, cities such as Barcelona and Pamplona remained under French rule. While all this was happening, the Mutiny of Aranjuez (17 March 1808) took place, led by Charles IV's own son, crown prince Ferdinand, and directed against him. Charles IV resigned and Ferdinand took his place as King Ferdinand VII. In May 1808, Napoleon's troops entered the city. On 2 May 1808 (Spanish: Dos de Mayo), the Madrileños revolted against the French forces, whose brutal behavior would have a lasting impact on French rule in Spain and France's image in Europe in general. Thus, Ferdinand VII returned to a city that had been occupied by Murat.

Both the king and his father became virtual prisoners of the French army. Napoleon, taking advantage of the weakness of the Bourbons, forced both, first the father and then the son, to meet him at Bayonne, where Ferdinand VII arrived on 20 April. Here Napoleon forced both kings to abdicate on 5 May, handing the throne to his brother Joseph Bonaparte.

On 2 May, the crowd began to concentrate at the Palacio Real and watched as the French soldiers removed the royal family members from the palace. On seeing the infante Francisco de Paula struggling with his captor, the crowd launched an assault on the carriages, shouting ¡Que se lo llevan! (They're taking him away from us!). French soldiers fired into the crowd. The fighting lasted for hours and is reflected in Goya's painting, The Second of May 1808, also known as The Charge of the Mamelukes. Meanwhile, the Spanish military remained garrisoned and passive. Only the artillery barracks at Monteleón under Captain Luis Daoíz y Torres, manned by four officers, three NCOs and ten men, resisted. They were later reinforced by a further 33 men and two officers led by Pedro Velarde y Santillán, and distributed weapons to the civilian population. After repelling a first attack under French General Lefranc, both Spanish commanders died fighting heroically against reinforcements sent by Murat. Gradually, the pockets of resistance fell. Hundreds of Spanish men and women and French soldiers were killed in this skirmish.

On 12 August 1812, following the defeat of the French forces at Salamanca, English and Portuguese troops entered Madrid and surrounded the fortified area occupied by the French in the district of Retiro. Following two days of Siege warfare, the 1,700 French surrendered and a large store of arms, 20,000 muskets and 180 cannon, together with many other supplies were captured, along with two French Imperial Eagles.

On 29 October, Hill received Wellington's positive order to abandon Madrid and march to join him. After a clash with Soult's advance guard at Perales de Tajuña on the 30th, Hill broke contact and withdrew in the direction of Alba de Tormes. Joseph re-entered his capital on 2 November.

After the war of independence Ferdinand VII returned to the throne (1814). The projects of reform by Joseph Bonaparte were abandoned; during the Fernandine period, despite the proposal of several architectural projects for the city, the lack of ability to finance those led to works often being postponed or halted.

After a liberal military revolution, Colonel Riego made the king swear to respect the Constitution. Liberal and conservative government thereafter alternated, ending with the enthronement of Isabella II.

Capital of the state
At the time the reign of Isabella II started, the city was still enclosed behind its walls, featuring a relatively slow demographic growth as well as very high population density. After the 1833 administrative reforms for the country devised by Javier de Burgos (including the configuration of the current province of Madrid), Madrid was to become the capital of the new liberal state.

Madrid experienced substantial changes during the 1830s. The corregimiento and the corregidor (institutions from the Ancien Regime) were ended for good, giving rise to the constitutional alcalde in the context of the liberal transformations. Purged off from Carlist elements, the civil office and the military and palatial milieus recognised legitimacy to the dynastic rights of Isabella II.

The reforms enacted by Finance Minister Juan Álvarez Mendizábal in 1835–1836 led to the confiscation of ecclesiastical properties and the subsequent demolition of churches, convents and adjacent orchards in the city (similarly to other Spanish cities); the widening of streets and squares ensued.

In 1854, amid economic and political crisis, following the pronunciamiento of group of high officers commanded by Leopoldo O'Donnell garrisoned in the nearby town of Vicálvaro in June 1854 (the so-called "Vicalvarada"), the 7 July Manifesto of Manzanares, calling for popular rebellion, and the ousting of Luis José Sartorius from the premiership on 17 July, popular mutiny broke out in Madrid, asking for a real change of system, in what it was to be known as the Revolution of 1854. With the uprising in Madrid reaching its pinnacle on 17, 18 and 19 July, the rebels, who erected barricades in the streets, were bluntly crushed by the new government.

1858 was a marked year for the city with the arrival of the waters from the Lozoya. The Canal de Isabel II was inaugurated on 24 June 1858. A ceremony took place soon after in Calle Ancha de San Bernardo to celebrate it, unveiling a 30-metre-high water source in the middle of the street. The plan for the Ensanche de Madrid ('widening of Madrid') by Carlos María de Castro was passed through a royal decree issued on 19 July 1860. The plan for urban expansion by Castro, a staunch Conservative, delivered a segregation of the well-off class, the middle class and the artisanate into different zones. The southern part of the Ensanche was at a disadvantage with respect to the rest of the Ensanche, insofar, located on the way to the river and at a lower altitude, it was a place of passage for the sewage runoff, thereby being described as a "space of urban degradation and misery". Beyond the Ensanches, slums and underclass neighborhoods were built in suburbs such as Tetuán, Prosperidad or Vallecas.

Student unrest took place in 1865 following the ministerial decree against the expression of ideas against the monarchy and the church and the forced removal of the rector of the Universidad Central, unwilling to submit. In a crescendo of protests, the night of 10 April 2,000 protesters clashed against the civil guard. The unrest was crudely quashed, leaving 14 deaths, 74 wounded students and 114 arrests (in what became known as the "Night of Saint Daniel"), becoming the precursor of more serious revolutionary attempts.

The Glorious Revolution resulting in the deposition of Queen Isabella II started with a pronunciamiento in the bay of Cádiz in September 1868. The success of the uprising in Madrid on 29 September prompted the French exile of the queen, who was on holiday in San Sebastián and was unable to reach the capital by train. General Juan Prim, the leader of the liberal progressives, was received by the Madrilenian people at his arrival to the city in early October in a festive mood. He pronounced his famous speech of the "three nevers" directed against the Bourbons, and delivered a highly symbolical hug to General Serrano, leader of the revolutionary forces triumphant in the 28 September battle of Alcolea, in the Puerta del Sol.

On 27 December 1870 the car in which General Prim, the prime minister, was travelling, was shot by unknown hit-men in the Turk Street, nearby the Congress of Deputies. Prim, wounded in the attack, died three days later, with the elected monarch Amadeus, Duke of Aosta, yet to swear the constitution.

The creation of the Salamanca–Sol–Pozas tram service in Madrid in 1871 meant the introduction of the first collective system of transportation in the city, predating the omnibus. The economy of the city further modernized during the second half of the 19th century, consolidating its status as a service and financial centre. New industries were mostly focused in book publishing, construction and low-tech sectors. The introduction of railway transport greatly helped Madrid's economic prowess, and led to changes in consumption patterns (such as the substitution of salted fish for fresh fish from the Spanish coasts) as well as further strengthening the city's role as a logistics node in the country's distribution network.

The late 19th century saw the introduction of the electric power distribution. As by law, the city council could not concede an industrial monopoly to any company, the city experienced a huge competition among the companies in the electricity sector. The absence of a monopoly led to an overlapping of distribution networks, to the point that in the centre of Madrid 5 different networks could travel through the same street. Electric lighting in the streets was introduced in the 1890s.

By the end of the 19th century, the city featured access to water, a central status in the rail network, a cheap workforce and access to financial capital. With the onset of the new century, the Ensanche Sur (in the current day district of Arganzuela) started to grow to become the main industrial area of the municipality along the first half of the 20th century. In the early 20th century Madrid undertook a major urban intervention in its city centre with the creation of the Gran Vía, a monumental thoroughfare (then divided in three segments with different names) whose construction slit the city from top to bottom with the demolition of multitude of housing and small streets. Anticipated in earlier projects, and following the signature of the contract, the works formally started in April 1910 with a ceremony led by King Alfonso XIII.

Also with the turn of the century, Madrid had become the cultural capital of Spain as centre of top knowledge institutions (the Central University, the Royal Academies, the Institución Libre de Enseñanza or the Ateneo de Madrid), also concentrating the most publishing houses and big daily newspapers, amounting for the bulk of the intellectual production in the country.

In 1919 the Madrid Metro (known as the Ferrocarril Metropolitano by that time) inaugurated its first service, which went from Sol to the Cuatro Caminos area.

In the 1919–1920 biennium Madrid witnessed the biggest wave of protests seen in the city up to that date, being the centre of innumerable strikes; despite being still surpassed by Barcelona's, the industrial city par excellence in that time, this cycle decisively set the foundations for the social unrest that took place in the 1930s in the city.

The situation the monarchy had left Madrid in 1931 was catastrophic, with tens of thousands of kids receiving no education and a huge rate of unemployment.

After the proclamation of the Second Republic on 14 April 1931 the citizens of Madrid understood the free access to the Casa de Campo (until then an enclosed property with exclusive access for the royalty), was a consequence of the fall of the monarchy, and informally occupied the area on 15 April. After the signing of a decree on 20 April which granted the area to the Madrilenian citizens in order to become a "park for recreation and instruction", the transfer was formally sealed on 6 May when Minister Indalecio Prieto formally delivered the Casa de Campo to Mayor Pedro Rico. The Spanish Constitution of 1931 was the first legislating on the state capital, setting it explicitly in Madrid. During the 1930s, Madrid enjoyed "great vitality"; it was demographically young, but also young in the sense of its relation with the modernity. During this time the prolongation of the Paseo de la Castellana towards the north was projected. The proclamation of the Republic slowed down the building of new housing. The tertiary sector gave thrust to the economy. Illiteracy rates were down to below 20%, and the city's cultural life grew notably during the so-called Silver Age of Spanish culture; the sales of newspaper also increased. Anti-clericalism and Catholicism lived side by side in Madrid; the burning of convents initiated after riots in the city in May 1931 worsened the political environment. The 1934 insurrection largely failed in Madrid.

In order to deal with the unemployment, the new Republican city council hired many jobless people as gardeners and street cleaners.

Prieto, who sought to turn the city into the "Great Madrid", capital of the Republic, charged Secundino Zuazo with the project for the opening of a south–north axis in the city through the northward enlargement of the Paseo de la Castellana and the construction of the Nuevos Ministerios administrative complex in the area (halted by the Civil War, works in the Nuevos Ministerios would finish in 1942). Works on the Ciudad Universitaria, already started during the monarchy in 1929, also resumed.


 * Botched coup

The military uprising of July 1936 was defeated in Madrid by a combination of loyal forces and workers' militias. On 20 July armed workers and loyal troops stormed the single focus of resistance, the Cuartel de La Montaña, defended by a contingent of 2,000 rebel soldiers accompanied by 500 falangists under the command of General Fanjul, killing over one hundred of rebels after their surrender. Aside from the Cuartel de la Montaña episode, the wider scheme for the coup in the capital largely failed both due to disastrous rebel planning and due to the Government delivering weapons to the people wanting to defend the Republic, with the city becoming a symbol of popular resistance, "the people in arms".
 * Siege

After the quelling of the coup d'état, from 1936–1939, Madrid remained under the control of forces loyal to the Republic. Following the seemingly unstoppable advance towards Madrid of rebel land troops, the first air bombings on Madrid also started. Immediately after the bombing of the nearing airports of Getafe and Cuatro Vientos, Madrid proper was bombed for the first time in the night of the 27–28 August 1936 by a Luftwaffe's Junkers Ju 52 that threw several bombs on the Ministry of War and the Station of the North. Madrid "was to become the first big European city to be bombed by aviation".

Rebel General Francisco Franco, recently given the supreme military command over his faction, took a detour in late September to "liberate" the besieged Alcázar de Toledo. Meanwhile, this operation gave time to the republicans in Madrid to build defenses and start receiving some foreign support. The summer and autumn of 1936 saw the Republican Madrid witness of heavy-handed repression by communist and socialist groups, symbolised by the murder of prisoners in checas and sacas directed mostly against military personnel and leading politicians linked to the rebels, which, culminated by the horrific Paracuellos massacres in the context of a simultaneous major rebel offensive against the city, were halted by early December. Madrid, besieged from October 1936, saw a major offensive in its western suburbs in November of that year.

In the last weeks of the war, the collapse of the republic was speeded by Colonel Segismundo Casado, who, endorsed by some political figures such as Anarchist Cipriano Mera and Julián Besteiro, a PSOE leader who had held talks with the Falangist fifth column in the city, threw a military coup against the legitimate government under the pretext of excessive communist preponderance, propelling a mini-civil war in Madrid that, won by the casadistas, left roughly 2,000 casualties between 5–10 March 1939.
 * Collapse

The city fell to the nationalists on 28 March 1939.

Following the onset of the Francoist dictatorship in the city, the absence of personal and associative freedoms and the heavy-hand repression of people linked to a republican past greatly deprived the city from social mobilization, trade unionism and intellectual life. This added to a climate of general shortage, with ration coupons rampant and a lingering autarchic economy lasting until the mid 1950s. Meat and fish consumption was scarce in Post-War Madrid, and starvation and lack of proteins were a cause of high mortality.

With the country ruined after the war, the Falange command had nonetheless high plans for the city and professionals sympathetic to the regime dreamed (based on an organicist conception) about the notion of building a body for the "Spanish greatness" placing a great emphasis in Madrid, what they thought to be the imperial capital of the New State. In this sense, urban planners sought to highlight and symbolically put in value the façade the city offered to the Manzanares River, the "Imperial Cornice", bringing projects to accompany the Royal Palace such as the finishing of the unfinished cathedral (with the start of works postponed to 1950 and ultimately finished in the late 20th century), a never-built "house of the Party" and many others. Nonetheless these delusions of grandeur caught up with reality and the scarcity during the Post-War and most of the projects ended up either filed, unfinished or mutilated, with the single clear success being the Gutiérrez Soto's Cuartel del Ejército del Aire.

The intense demographic growth experienced by the city via mass immigration from the rural areas of the country led to the construction of plenty of housing in the peripheral areas of the city to absorb the new population (reinforcing the processes of social polarization of the city), initially comprising substandard housing (with as many as 50,000 shacks scattered around the city by 1956). A transitional planning intended to temporarily replace the shanty towns were the poblados de absorción, introduced since the mid-1950s in locations such as Canillas, San Fermín, Caño Roto, Villaverde, Pan Bendito, Zofío and Fuencarral, aiming to work as a sort of "high-end" shacks (with the destinataries participating in the construction of their own housing) but under the aegis of a wider coordinated urban planning.

Together with the likes of Cairo, Santiago de Chile, Rome, Buenos Aires or Lisbon, Francoist Madrid became an important transnational hub of the global Neofascist network that facilitated the survival and resumption of (neo)fascist activities after 1945.

In the 1948–1954 period the municipality greatly increased in size through the annexation of 13 surrounding municipalities, as its total area went up from 68,42 km2 to 607,09 km2. The annexed municipalities were Chamartín de la Rosa (5 June 1948), Carabanchel Alto (29 April 1948), Carabanchel Bajo (29 April 1948), Canillas (30 March 1950), Canillejas (30 March 1950), Hortaleza (31 March 1950), Barajas (31 March 1950), Vallecas (22 December 1950), El Pardo (27 March 1951), Vicálvaro (20 October 1951), Fuencarral (20 October 1951) Aravaca (20 October 1951) and Villaverde (31 July 1954).

The population of the city peaked in 1975 at inhabitants.

Recent developments
Benefiting from prosperity in the 1980s, Spain's capital city has consolidated its position as the leading economic, cultural, industrial, educational and technological center of the Iberian peninsula. The relative decline in population since 1975 reverted in the 1990s, with the city recovering a population of roughly 3 million inhabitants by the end of the 20th century.

Since the late 1970s and through the 1980s Madrid became the center of the cultural movement known as la Movida. Conversely, just like in the rest of the country, a heroin crisis took a toll in the poor neighborhoods of Madrid in the 1980s.

During the mandate as mayor of José María Álvarez del Manzano, construction of traffic tunnels below the city proliferated. On 11 March 2004, three days before Spain's general elections and exactly 2 years and 6 months after the September 11 attacks in the US, Madrid was hit by a terrorist attack when Islamic terrorists belonging to an al-Qaeda-inspired terrorist cell placed a series of bombs on several trains during the morning rush hour, killing 191 people and injuring 1,800. The administrations that followed Álvarez del Manzano's, also conservative, led by Alberto Ruiz-Gallardón and Ana Botella, launched three unsuccessful bids for the 2012, 2016 and 2020 Summer Olympics. Madrid was a centre of the anti-austerity protests that erupted in Spain in 2011. As consequence of the spillover of the 2008 financial and mortgage crisis, Madrid has been affected by the increasing number of second-hand homes held by banks and house evictions. The mandate of left-wing Mayor Manuela Carmena (2015–2019) delivered the renaturalization of the course of the Manzanares across the city.

Since the late 2010s, the challenges the city faces include the increasingly unaffordable rental prices (often in parallel with the gentrification and the spike of tourist apartments in the city centre) and the profusion of betting shops in working-class areas, equalled to an "epidemics" among the young people.