The capital city of Spain has a long and colorful history dating from as far back as 1000 BC with the earliest recorded settlement by Iberian and Celtic tribes in the area. It was then occupied by the Romans who used it as a passageway to the rest of Spain. When the Roman empire fell, it was overtaken for a brief period by the Visigoth tribes. However, it was under the Muslim rule during the late 9th century to the 11th century that Madrid started charting its path towards becoming the modern city that it is today. Officially founded and named Mayrit (in some history books the city’s name was Magerit) - referring to its location by the Manzanares River, the city was established as a fortress by the Emir Muhammad I of Cordoba. With the ensuing wars between the Christians and the Muslims, the area repeatedly suffered conquests from both groups until the late 11th century when Madrid was won by Alfonso VI. Henry III of Castile oversaw the rebuilding of the city after several more clashes with the Muslims, and in the middle of the 16th century, Philip II moved the royal court of Spain from Toledo to Madrid.
The 17th to 18th centuries saw the rise of Madrid as a political, economic and cultural center. Under the reign of Charles III, the city underwent massive development – from the completion of the Palacio Real, the construction of the city gates of Puerta de Toledo and Puerta de Alcala, along with the other historic buildings and monuments such as the Royal Theatre, the Royal Mint and the fountain of Cibeles. During this period as well, the city has attracted many Spanish artists and writers who will become icons in their fields: Miguel de Cervantes and Diego Velazquez to name a few. More building efforts took place under Carlos IV. However, it was also during this time that the people of the city revolted under the leadership of his own son Ferdinand VIII. Although he assumed the throne after his father stepped down, the French troops led by Napoleon Bonaparte invaded and occupied the city in the 19th century.
In an effort to regain their city, the Madrilenos rose up in arms against the French troops in 1808 – starting the War of Independence. The wars went on until 1813 when the French troops finally left the city and Fernando VII assumed the throne in Madrid.
More civil wars ensued from the 19th to the early 20th centuries, the most dramatic of which was the Spanish Civil War in the 1930s. Madrid was besieged by the Nationalist forces of Francisco Franco who ruled the country as a dictator. Having rebuilt itself from the ravages of wars, Madrid experienced development and expansion, both in terms of economic and population growth during the 1960s. The Spanish economic boom benefitted the city a lot and it became the third city in Western Europe with the largest GDP. In 1975, Franco died and the country was transformed to a democratic constitutional monarchy and Juan Carlos I was named as King. From then on, Madrid has solidified its position in the country and the European continent as a major financial, cultural, educational and technological hub.