Separated from western Europe by the Pyrenees and from Africa by the Strait of Gibraltar, the Iberian Peninsula (occupied by Spain and Portugal) was long an attractive target for expanding Mediterranean empires and greedy outsiders.
Around 1100 BC southern Iberia was colonized by the Phoenicians, and by 220 BC, the Romans and their culture dominated the entire peninsula. When the Roman Empire faded, assorted ethnic groups settled in, and the forceful Visigoths eventually ruled.
In the early 700's, Muslim forces from North Africa crossed the Strait of Gibraltar and their culture and traditions subsequently influenced most of the peninsula for the next 800 years.
Christianity revived itself (albeit slowly) during the Muslim era, and when Fernando, heir to the throne of Aragon, and Princess Isabel of Castille married in 1469, large Christian parts of Spain were now united as one.
Their forces overran Granada, and the last Muslim stronghold surrendered. Now known as the 'Catholic Monarchs,' Fernando and Isabel resumed the Spanish Inquisition ( or Reconquest), a time of aggressive religious persecution, where Muslims, Jews and other non-Christians were expelled and/or executed.
The royal couple supported expeditions to the New World by Columbus, and other explorers like Balboa, Cotez and Magellan. Untold riches flowed into Spain from their new colonies in the Americas, and Spain became a powerful country.
In fact, in the 16th and 17th centuries (under the Habsburgs), with its colonies spread across the Americas and its navy dominating the oceans, the Spanish Empire literally became the first global superpower. At home it was enjoying a so-called Golden Age, as the creative geniuses of Cervantes, El Greco, Lope de Vega and Velazquez (and others) produced enduring masterpieces, international law was born, and Spain was now writing its own cultural history.
In 1808, shortly after Louis XVI was guillotined in France, Napoleon's troops crossed the Pyrenees into Spain. The Spanish people resisted and after a five-year war of independence, French forces were finally expelled, and the Spanish throne restored.