Although the site of modern-day Madrid has been occupied since pre-historic times, in the Roman age this territory belonged to the diocese of Complutum (present-day Alcalá de Henares). But the first historical data on the city comes from the 9th century, when Muhammad I ordered the construction of a small palace in the same place that is today occupied by the Palacio Real. Around this palace a small citadel, al-Mudaina, was built. From this came the naming of the site as Majerit, which was later rendered to the modern-day spelling of Madrid). The citadel was conquered in 1085 by Alfonso VI of Castile in his advance towards Toledo. He reconstructed the mosque as the church of the Virgin of Almudena (almudin, the garrison’s granary). In 1329, the Cortes Generales first assembled in the city to advise Ferdinand IV of Castile. Sephardi Jews and Moors continued to live in the city until they were expelled at the end of the 15th century. After troubles and a large fire, Henry III of Castile (1379-1406) rebuilt the city and established himself safely fortified outside its walls in El Pardo. The grand entry of Ferdinand and Isabella to Madrid heralded the end of strife between Castile and Aragon.
The Kingdom of Castile, with its capital at Toledo, and the Crown of Aragon, with its capital at Zaragoza, were welded into modern Spain by the Catholic Monarchs (Queen Isabella of Castile and King Ferdinand II of Aragon). Though their grandson Charles I of Spain (also known as Charles V, Holy Roman Emperor favored Madrid, it was Charles´ son, Philip II (1527-1598) who moved the court to Madrid in 1561. Although he made no official declaration, the seat of the court was the de facto capital. Sevilla continued to control commerce with Spain’s colonies, but Madrid controlled Sevilla. Aside from a brief period, 1601-1606, when Felipe III installed his court in Valladolid, Madrid’s fortunes have closely mirrored those of Spain. During the Siglo de Oro (Golden Century), in the 16th/17th century, Madrid had no resemblance with other European capitals: the population of the city was economically dependent on the business of the court itself.
Felipe V, Spain’s first Bourbon King and, therefore, French, decided that a European capital could not stay in such a state, and new palaces (including the Palacio Real de Madrid) were built during his reign. However, it would not be until Carlos III (1716-1788) that Madrid would become a modern city. Carlos III was one of the most popular and benevolent Kings in the history of Madrid. He was popularly known at the time (and henceforth) as Madrid’s best mayor. When Carlos IV (1748-1819) became King of Spain, the people of Madrid revolted. After the Mutiny of Aranjuez, which was led by his own son Fernando VII against him, Carlos IV resigned, but Fernando VII’s reign would be short: in May 1808 Napoleon’s troops entered the city. On May 2, 1808 (Spanish: Dos de Mayo) the Madrileños revolted against the invading French army, whose brute reaction would have a lasting impact on French rule in Spain and France’s image in Europe in general.
After the war of independence (1814) Fernando VII came back to the throne, but soon after, a liberal military revolution, Colonel Riego made the King swear allegiance to Spain’s new (and first) Constitution. This would start a period where liberal and conservative governments alternated in power, which would end with the enthronement of Isabel II (1830-1904).
Isabel II could not suppress the political tension that would lead to yet another revolt, the First Spanish Republic, and the return of the monarchy, which eventually led to the Second Spanish Republic and the Spanish Civil War. During this war (1936-1939) Madrid was one of the most affected cities of Spain and its streets became battlegrounds. Madrid was a stronghold of the Republicans from July 1936. Its western suburbs were the scene of an all-out battle in November 1936. It was during the Civil War that Madrid became the first city to be bombed by airplanes specifically targeting civilians in the history of warfare.
During the dictatorship of Francisco Franco, especially during the 1960s, the south of Madrid became very industrialized and there were massive migrations from rural environments into the city. Madrid’s south-eastern periphery became an extensive slum settlement, which was the base for an active cultural and political reform. After the death of Franco, emerging democratic parties (including those of left-wing and republican ideology) accepted Franco’s wishes of being succeeded by Juan Carlos I – in order to secure stability and democracy – which led Spain to its current position as constitutional monarchy.
Befitting from the prosperity it gained in the 1980s, the capital city of Spain has consolidated its position as the leading economic, cultural, industrial, educational, and technological center on the Iberian peninsula. On 11 March 2004, Madrid was hit by a terrorist attack when terrorists placed a series of bombs on multiple trains during the rush hour, three days before the 14 March 2004 elections. This was the worst massacre in Spain since the end of the civil war in 1939. Madrid suffered another terrorist attack, on the part of ETA, 30 December 2006. An explosion took place in the building attached to Terminal 4 of Madrid Barajas International Airport.