The earliest recorded history of the place now called Madrid dates from the ninth century. At that time, it was the site of a Moorish fortress called Magerit – in old Arabic, “place of water”. The abundance of water would prove key in the development of the settlement that became the capital of a united Spain.


Long before the Moors, came the Romans. They invaded the Iberian peninsula from the late third century BC, but paid little attention to this little backwater; they were after much bigger prizes such as Cádiz. The Visigoths, arriving in the sixth century AD, integrated it into their kingdom of Toledo, but even so it remained an insignificant outpost for many years.

Madrid’s shifting religions

In AD 711, a force of Arabs and Berbers crossed the Strait of Gibraltar from north Africa, launching a wave of conquest that created the vast, Muslim-ruled kingdom of Al-Andalus, spanning most of the Iberian peninsula.

The following century, Moorish emir Muhammad I ordered the construction of a fortified citadel at the place dubbed Magerit, on a site now occupied by Madrid’s Royal Palace. Little evidence of the Moorish occupation remains today, though you can find some sections of their wall near the palace and La Almudena Cathedral, in Emir Mohamed I Park.

History's Greatest Cities: A HistoryExtra podcast series

This companion piece accompanies our podcast miniseries History's Greatest Cities. Listen to the full episode on Florence with Jules Stewart and Paul Bloomfield, then explore the entire series

The settlement gained prominence when Alfonso VI of León and Castile took Magerit from the Moors in 1085 during the so-called Reconquista (Reconquest) of Spain by Christian forces.

One traditional tale recounts an incident involving the soldier who became known as El Gato – ‘the cat’. On reaching Magerit’s defences – so the story goes – he jumped off his horse, scampered up the wall, ripped down the Moorish banner and put up the Christian flag.

One of his fellow Christians said: look, he climbs like a cat. Today Gato is a nickname for a Madrileño (resident of Madrid) – though it can be claimed only by a resident of the third generation or older.

Madrid as a medieval metropolis

A photo of Casadela Villa under a blue sky
Casadela Villa in Madrid. (Photo by Getty Images)

For a long time, Madrid remained a small, obscure agricultural settlement. A few notable monuments from that period remain, including the medieval Torre e Casa de los Lujanes (Tower and House of the Lujanes), just off the Calle Mayor, near the San Miguel market and the Casa de la Villa (old town hall). Built in the late 15th century for the prominent Lujan family, it's a remarkable example of late Mudejar-style architecture.

During the Middle Ages, Madrid’s population was quite diverse. Moors, Jews and Christians managed to get on; indeed, as far as the Iberian Jews were concerned, they owed allegiance to whoever happened to be in charge, and were allowed to get on with their lives largely without persecution until 1492, when they were expelled from Spain. Today, only plaques mark the locations of their ghettos.

The big change for Madrid came in 1561, when the Habsburg king Philip II decided to up sticks and move his court there from Toledo. There are many reasons why he may have chosen to do this: one persuasive idea is Philip wanted to get on with ruling the Spanish empire, so tried to put some distance between himself and the influence of the Catholic church, which was based in Toledo.

Another strong argument is that it was a response to the need for a reliable and substantial supply of water. Toledo was growing rapidly, but its only source of water was the Tagus River, in a deep gorge far below the city; it became increasingly difficult to provide enough drinking water for the population. Madrid, on the other hand, had much better access to water, from the Manzanares River. It was also geographically the centre of the Iberian trade routes, and had a much more benign climate – to begin with, at least.

When Philip arrived, he had in tow perhaps 7,000 people, all of whom needed housing and firewood. Madrid was surrounded by forests, which were plundered for wood. Certainly, enough of the trees protecting Madrid from the fierce winds of the Guadarrama mountains to the north disappeared that the climate changed radically. There’s a saying describing the weather in Madrid: Nueve meses de invierno y tres mese de infierno – nine months of winter and three of hell.

Philip – who had a tough act to follow as the son of the powerful Holy Roman Emperor Charles V – wanted to make his mark on his new capital and the surrounding area. Shortly after arriving in Madrid, he ordered the foundation of a royal monastery in the hills some 25 miles to the north-west: the Real Monasterio de San Lorenzo de El Escorial, or simply El Escorial.

A photo of the Monastery of San Lorenzo de El Escorial
The Monastery of San Lorenzo de El Escorial. (Photo by Marques Photography, via Getty Images)

This vast complex – the world’s largest Renaissance structure – incorporates numerous elements, including a basilica, library, university and palace. Even today it’s a spectacular place to visit on a day trip from the city.

Madrid after the Habsburgs

Philip’s successors didn’t even live up to his own standards, much less the reputation of Charles V, but the last Habsburg king – Charles II – was a particularly sad case.

Suffering from near-constant ill health and physical disabilities – including the notorious ‘Habsburg jaw’ – his reign was defined by political crises and his inability to produce heirs. Hs death in 1700 ended Habsburg rule in Spain and precipitated a dynastic conflict that would become know as the War of the Spanish Succession, in which various factions fought for control of not only the kingdom but also its extensive empire.

In 1714, the victorious house of Bourbon moved in, and it still occupies the Spanish throne to this day. And they did a lot for Madrid.

They centralised the system of government, enhancing Madrid's power as the capital of the Spanish empire. They launched a period of architectural glory., building the current Royal Palace, Europe's largest, to replace the Alcázar, which had stood on the site since the ninth century but which was destroyed by fire in 1734.

A photo of the Puerta de Alcala illuminated at dusk.
The Puerta de Alcala monumental gate illuminated at dusk. (Photo by Getty Images)

They built the Puerta de Alcalá, Europe’s first modern post-Roman triumphal arch, completed in 1778, and the Conde Duque Barracks – now a heritage site and a magnificent cultural centre – designed by the architect Pedro de Ribera. He also built the Baroque Royal Hospice of San Fernando, which now houses the Museum of History of Madrid on Calle de Fuencarral.

Madrid during the Napoleonic wars

Madrid was occupied by French forces in March 1808, during Napoleon’s peninsular campaign. This sparked one of the most important events in the city’s history: the Dos de Mayo (Second of May) Uprising, when some 2,000 Madrileños attempted to drive out the invaders. Although crushed and resulting in harsh punitive measures, it inspired further revolts in Spain and was depicted by Goya. His work ‘The Third of May, 1808’, showing resistance fighters being executed by French troops, is on display at the Prado Museum.

The uprising is remembered and commemorated around Madrid, and 2 May is a public holiday. Some of the people involved have become heroes, such as Manuela Malasaña, a teenage seamstress who joined the fighting armed only with her scissors – and who was summarily executed. The district in which she lived is now named in her honour, with the Plaza de Dos de Mayo at its heart.

After the French forces were turfed out in 1813, and the king installed by Napoleon – his brother Joseph, derisively dubbed Pepe Botella (meaning Joe Bottle) by his unwilling Spanish subjects – was ousted, the Bourbons returned to the throne. But they could not stop Spain gradually losing its influence over its global empire. This culminated in 1898 with the Spanish-American War, which resulted in the loss of its last imperial possessions, including Cuba, the Philippines and Puerto Rico.

Madrid, no longer the capital of an empire, declined accordingly as Spain entered a period of political instability. The First Spanish Republic came and went, lasting less than two years (1873–74) before a coup; Miguel Primo de Rivera's dictatorship (1923–30) also failed to last. The people of Madrid became used to political chaos, and just got on with life.

Madrid in the Spanish Civil War

Events took a much darker turn after Alfonso XIII went into exile in 1931. The Second Spanish Republic, founded after Alfonso was deposed, lasted only a few years. The government, composed largely of socialist, communists and a number of anarchists, frightened certain elements within society, particularly in the military and the Catholic Church. A coup in 1936 brought about the Spanish Civil War and the rise of General Francisco Franco. In the process, Madrid became a besieged city, its people living in the most horrendous conditions.

Franco brought the Foreign Legion and other north African troops and marched on Madrid. But there he was stopped. For nearly three years he was unable to enter the city, which suffered constant aerial bombardments and shelling. The Telefónica building – Europe’s tallest skyscraper when it opened in 1930 – was a frequent target as Republican forces used it as a lookout point. It’s still a striking building today.

In March 1939, Franco’s Nationalist forces took the capital, marking the end of the bloody civil war. The city was extremely badly damaged, and a period of reconstruction began. Thousands of people from villages around Spain flooded in; to agricultural workers, the opportunity to earn a salary on a scaffold seemed preferable to herding goats. This fact lends Madrid its diverse character: very few people who live here are actually from the city.

Madrid after Franco

Though officially neutral during the Second World War, Spain maintained close ties to Nazi Germany and Fascist Italy. As a result, after the conflict ended, the country – still led by Franco – became an international pariah. Spain was not in the United Nations, the Common Market, the International Monetary Fund or any of the other organisations that rebuilt Europe. Slowly, though, from the 1950s it emerged from that period of moribund economy.

By the time of Franco’s death in November 1975, the country had been transformed. The transition to democracy was largely peaceful, though the first couple of years were worrisome as there were still many right-wing supporters on the streets, and the fascist youth organisation Fuerza Nueva committed some atrocities. But this period also saw the emergence of La Movida Madrileña, a countercultural movement that pushed for political and economic change. It also witnessed an artistic flourishing, not least in music, with a growing punk and synth-pop scene.

Today, Madrid is a thriving, cosmopolitan city that offers a good life – if you've got the stamina for it. Put it this way: don’t think about going out before 11pm. As hard-living American writer Ernest Hemingway said – as far back as the 1920s – the worst traffic jams in Madrid start building up around midnight. It truly feels like a city that never sleeps.

Jules Stewart was talking to Paul Bloomfield, travel journalist and host of our podcast series History's Greatest Cities

What to see: Madrid in five places

A Moorish citadel that became an imperial capital, Madrid today is a cosmopolitan city. Jules Stewart picks five unmissable sites that illuminate its history

Map of central Madrid with five locations marked

1. Chapel of San Antonio de la Florida

Photo of a fresco on the Chapel of San Antonio

Side by side on the banks of the Manzanares river stand a pair of modest domed chapels. One is the Chapel of San Antonio de la Florida, completed on the orders of Charles IV in 1798. Dedicated to Saint Anthony of Padua, each 13 June it draws crowds of young women, hoping to be married.

But to really understand the chapel’s importance, look up. The ceiling vaults, spandrels and dome are adorned with astonishing frescoes by Francisco Goya, the great Spanish painter of the late 18th and early 19th centuries, depicting angels and scenes including Saint Anthony raising a man from the dead.

Later in life, Goya was much affected by his experiences during the Napoleonic French occupation of Madrid and the popular uprising on 2 May 1808, which inspired many later works. He died in France in 1828, but his remains were returned to Spain decades later, and he now lies in this chapel. In 1928, an identical copy of the chapel was built alongside it, to enable continued worship while preserving the original – hence the unusual twin monuments.

2. Joaquín Sorolla Museum

Photo inside the Joaquin Sorolla Museum

Another Spanish artist of renown in his homeland, but less well-known internationally, was Joaquín Sorolla y Bastida (1863–1923). Born in Valencia, he spent many years in Madrid, where his last home in the central Chamberí neighbourhood is now an immersive museum. As well as his belongings, letters and photographs, it houses more than 1,200 of his paintings and drawings.

Sorolla’s portraits, landscapes and other works open a window onto Spanish life around the end of the 19th and early 20th century. These include episodes from Madrid’s history as well as depictions of everyday life: sick children sea-bathing, people at work, and so on.

3. Atocha Station

Photo of Atocha Station

Madrid’s first railway station was inaugurated on 9 February 1851, for the opening of the line linking the capital with the small town of Aranjuez, about 30 miles to the south. That small stop, then called Estación de Mediodía, was rebuilt in 1892 to create Atocha Station, hub of Europe’s biggest high-speed rail network.

It’s a magnificent structure, with a vast wrought-iron roof that was designed in collaboration with Gustave Eiffel. In 1992 the building was taken out of service, and its majestic halls now play host to exotic tropical plants and a terrapin pool.

Outside stands a moving memorial to the 191 victims of the attack by Islamist suicide bombers on 11 March 2004 – one of the darkest days in Madrid’s history.

4. Museo del Romanticismo

Photo of a statue in a garden at the Museo del Romanticismo

In the first half of the 19th century, a cultural movement swelled in Spain, influencing artists, thinkers, even politicians: Romanticism. The museum dedicated to that movement, housed in a gorgeous 1776 palace, not only displays artworks by the likes of Goya and Esquivel, it also recreates rooms of the period to give a sense of how the bourgeoisie involved lived.

You can wander among period furniture, pianos, ceramics, even dolls, and roam the lovely Magnolia Garden, which is designed in the 18th-century French style.

5. Plaza del Dos de Mayo

Photo of a statue at the Plaza del Dos de Mayo

On 2 May 1808, some 2,000 Madrileños rose up against the Napoleonic French occupying forces – a revolt that was crushed (the French remained for five more years) but which is still emblematic of the fierce spirit of the capital and its citizens. The Plaza del Dos de Mayo, named to commemorate that episode, is the heart of the still-vibrant Malasaña district.

Visit Café Manuela, named after the seamstress Manuela Malasaña, a heroic figurehead of the uprising who was attacked by French troops. When they tried to rape her, she defended herself with a pair of scissors – and was summarily put up against the wall and executed.

Both the Plaza del Dos de Mayo and the district are named in her memory. In the late 1970s and 80s the cafe was a focal point of the Movida Madrileña, a countercultural movement that pushed for political and economic change but which also nurtured a flourishing punk and synth-pop scene.

Today it evokes a fin de siècle atmosphere, and is a popular spot for playing board games.


Jules Stewart is the author of a dozen books, including Madrid: The History (IB Tauris, 2012) and, with Helen Crisp, Madrid: Midnight City (Reaktion, 2020). He was talking to Paul Bloomfield. Listen to the companion podcast on Madrid or explore the entire series


Jules StewartJournalist and author

Jules Stewart is a journalist and author. His books include Madrid, The History, Madrid: A Literary Guide for Travellersand, co-written with Helen Crisp, Madrid: Midnight City