The Napoleonic invasion gave the opportunity to the American colonies, led by Libertadores, to claim their independence. Between 1810 and 1824, Chile, Colombia, Ecuador, Venezuela, and the other colonies declared and won their independence. The only New World colonies Spain was left with were the islands of Cuba and Puerto Rico. The Allies fought Napoleon's forces in the Peninsular War, with Joseph Bonaparte ruling as king at Madrid. In 1812 the Cortes took refuge at Cádiz and created the first modern Spanish constitution, the Constitution of 1812 (informally named La Pepa).
Spain's natural surroundings have helped shape the culture of the nation. The success of the Basques in maintaining a separate culture over a period of millennia has doubtless been aided by the mountainous geography of their region. Several separate parts of Spain have strong maritime traditions, including inland ports on rivers: Seville, for example, was a major port until the Guadalquivir silted up. Since the availalability of mass air transport, Spain's Mediterranean beaches, especially those along the Costa del Sol, have drawn millions of tourists, providing considerable revenue (and enormous contact with the outside world) to a long-depressed and isolated area of the country.
As the Roman empire declined, the Suebi, Vandals and Alans each took control of part of Hispania. In the 5th century AD the Visigoths, a romanized germanic tribe, conquered all of Hispania and established a relatively stable kingdom lasting until 711, when it fell to an invasion by Islamic North African Moors and became part of the expanding Umayyad empire, under the name of Al-Andalus. When the Umayyad empire gave way to the Abbaside empire, an Umayyad exile established the Caliphate of Cordoba, effectively making Al-Andalus independent from the empire.
As recently as the mid-20th-century, much of Spain (especially outside of the major cities) remained quite distinct from the rest of Europe. In 1954, V.S. Pritchett could still write of small Spanish towns, "The inn, if there is one, will not be a hotel, nor even a fonda — the Arab word — but perhaps a posada: a place one can ride into with a mule or a donkey, where one can stable an animal and lie down oneself on a sack of straw, the other side of the stall." [Pritchett, 1954 p. 46-47] However, especially since the 1975 death of Francisco Franco, Spain has become increasingly European; Pritchett's rustic posada would be unimaginable today.
The crown jewel of Spain's next decade of infrastructure construction is the Spanish high speed rail network, Alta Velocidad Española AVE. Currently, an ambitious plan includes the construction of a 7000 km network, centered naturally on Madrid. The overall goal is to have all important provincial cities be no more than 4 hours away from Madrid, and no more than 6 hours away from Barcelona. Currently, AVE high-speed trains link Atocha station to Seville in the south and Lleida in the east (to be extended to Barcelona).
In 1898 Spain lost the Spanish-American War. Cuba gained its independence, and Spain lost its remaining New World colonies—Guam, the Philippines, and Puerto Rico—to the United States. Spain's colonial possessions were reduced to Spanish Morocco, Western Sahara and Equatorial Guinea.
According to the latest official poll, 80% of Spaniards self-identify as Catholic, 12% as non-believer, and 1% as other (the remaining 7% declined to state). Of the 1.4% identifying as other, 29% identified as Evangelical Christian, 26% as Jehovah's Witnesses and 3% as Muslim (the rest either mentioned smaller religions or declined to state). According to the same poll, 73% believe in God, 14% don't and 12% are unsure (1% declined to state). Additionally, according to this poll, only 41% believe in Heaven. 24% of the Spaniards think that the Bible is just a fable. Only 25% of Catholics go to church at least once a week.
Spain is considered by many, including a large part of Spanish population, to be a group of nations unified under a single State, much like Belgium, Switzerland or the United Kingdom. Despite this, the policy of many Spanish governments has led to a "Spanish nationhood" which is the one people identify with Spain internationally.
Under the Bonaparte, Spain failed to embrace the mercantile and industrial revolutions of the 18th century, and also failed to absorb the ideals that of the Enlightenment that were revolutionizing European thought. These missed opportunities, combined with the economic failures of the 17th century, caused the country to fall desperately behind Britain, France, and Germany in economic and political power.
With the approval of the Spanish Constitution of 1978 and the arrival of democracy, the old historic nationalities — Basque Country, Catalonia, Galicia and Andalusia— were given far-reaching autonomy, which was then soon extended to all Spanish regions, resulting in one of the most decentralized territorial organizations in Western Europe.
Roman Catholicism is, by far, the most popular religion in the country, with four in five Spaniards (80%) self-identifying as Catholics. The next group (one in eight, or 12%) is represented by atheists or agnostics. Minority religions account for one in seventy (1.4%) of all Spaniards.