Spain in the 19th century was a country in turmoil. Occupied by
Napoleon from 1808 to 1814, a massively destructive "
war of independence" ensued, driven by an emergent Spanish
nationalism. An era of reaction against the
liberal ideas associated with revolutionary France followed the war, personified by the rule of
Ferdinand VII and – to a lesser extent – his daughter
Isabella II. Ferdinand's rule included the loss of the
Spanish colonies in the
New World, except for
Cuba and
Puerto Rico, in the 1810s and 1820s. A series of civil wars then broke out in Spain, pitting Spanish liberals and then
republicans against conservatives, culminating in the
Carlist Wars between the moderate Queen Isabella and her uncle, the reactionary
Infante Carlos. Disaffection with Isabella's government from many quarters led to repeated military intervention in political affairs and to several revolutionary attempts against the government. Two of these revolutions were successful, the moderate
Vicalvarada or "Vicálvaro Revolution" of 1854 and the more radical
la Gloriosa (Glorious Revolution) in 1868. The latter marks the end of Isabella's monarchy. The brief rule of the liberal king
Amadeo I of Spain ended in the establishment of the
First Spanish Republic, only to be replaced in 1874 by the popular, moderate rule of
Alfonso XII of Spain, which finally brought Spain into a
period of stability and reform.