The history of Spain dates back to the Early Middle Ages. In 1516, Habsburg Spain unified a number of disparate predecessor kingdoms; its modern form of a constitutional monarchy was introduced in 1813, and the current democratic constitution dates to 1978.
After the completion of the Reconquista, the kingdoms of Spain were united under Habsburg rule in 1516. At the same time, the Spanish Empire began to expand to the New World across the ocean, marking the beginning of the Golden Age of Spain, during which, from the early 1500s to the 1650s, Habsburg Spain was among the most powerful states in the world.
During this period, Spain was involved in all major European wars, including the Italian Wars, the Eighty Years' War, the Thirty Years' War, and the Franco-Spanish War. In the later 17th century, however, Spanish power began to decline, and after the death of the last Habsburg ruler, the War of the Spanish Succession ended with the relegation of Spain, now under Bourbon rule, to the status of a second-rate power with a reduced influence in European affairs. The so-called Bourbon Reforms attempted the renewal of state institutions, with some success, but as the century ended, instability set in with the French Revolution and the Peninsular War, so that Spain never regained its former strength.
Fragmented by the war, Spain at the beginning of the 19th century was destabilised as different political parties representing "liberal", "reactionary", and "moderate" groups throughout the remainder of the century fought for and won short-lived control without any being sufficiently strong to bring about lasting stability. The former Spanish Empire overseas quickly disintegrated with the Latin American wars of independence and eventually the loss of what old colonies remained in the Spanish–American War of 1898.
A tenuous balance between liberal and conservative forces was struck in the establishment of constitutional monarchy during 1874–1931 but brought no lasting solution, and Spain descended into Civil War between the Republican and the Nationalist factions.