In the second half of the 9th century, the emir of Córdoba, Muhammad I (852–886), built a fortress on a promontory beside the river, the modern-day location of the Royal Palace.
Its purpose was to watch the passes of the Sierra de Guadarrama and to initiate raids against the northern Christian countries.
Philip II chose to place his court in Madrid in 1561, ensuring the swift evolution of the town.
The Bourbon kings, especially Carlos III, fixated on converting Madrid into a great capital, using Paris as a model.
The reign of Isabella II saw the construction of the Congress of Deputies building, in Puerta del Sol.