In 1793, Spain went to war against the revolutionary new French Republic as a member of the first Coalition. The subsequent War of the Pyrenees polarised the country in a reaction against the gallicised elites and following defeat in the field, peace was made with France in 1795 at the Peace of Basel in which Spain lost control over two-thirds of the island of Hispaniola. In 1807, a secret treaty between Napoleon and the unpopular prime minister led to a new declaration of war against Britain and Portugal. French troops entered the country to invade Portugal but instead occupied Spain’s major fortresses. The Spanish king abdicated and a puppet kingdom satellite to the French Empire was installed with Napoleon’s brother Joseph Bonaparte as king.
The 2 May 1808 revolt was one of many uprisings across the country against the French occupation. These revolts marked the beginning of a devastating war of independence against the Napoleonic regime.
Further military action by Spanish armies, guerrilla warfare and an Anglo-Portuguese allied army, combined with Napoleon’s failure on the Russian front, led to the retreat of French imperial armies from the Iberian Peninsula in 1814, and the return of King Ferdinand VII.
During the war, in 1810, a revolutionary body, the Cortes of Cádiz, was assembled to co-ordinate the effort against the Bonapartist regime and to prepare a constitution. It met as one body, and its members represented the entire Spanish empire. In 1812, a constitution for universal representation under a constitutional monarchy was declared, but after the fall of the Bonapartist regime, the Spanish king dismissed the Cortes Generales, set on ruling as an absolute monarch.
The French occupation of Mainland Spain created an opportunity for overseas criollo elites who resented the privilege towards Peninsular elites and demanded retroversion of the sovereignty to the people. Starting in 1809 the American colonies began a series of revolutions and declared independence, leading to the Spanish American wars of independence that put an end to the metropole’s grip over the Spanish Main. Attempts to re-assert control proved futile with opposition not only in the colonies but also in the Iberian peninsula and army revolts followed, led by liberal officers. By the end of 1826, the only American colonies Spain held were Cuba and Puerto Rico.
The Napoleonic War left Spain economically ruined, deeply divided and politically unstable. In the 1830s and 1840s, Carlism (a reactionary legitimist movement supportive of an alternative Bourbon branch), fought against the government forces supportive of Queen Isabella II’s dynastic rights in the Carlist Wars. Government forces prevailed, but the conflict between progressives and moderates ended in a weak early constitutional period. The 1868 Glorious Revolution was followed by the 1868–1874 progressive Sexenio Democrático (including the short-lived First Spanish Republic), which yielded to a stable monarchic period, the Restoration (1875–1931), a rigid bipartisan regime underpinned by the turnismo (the prearranged rotation of government control between liberals and conservatives) and the form of political representation at the countryside (based on clientelism) known as caciquismo [es].
In the late 19th century nationalist movements arose in the Philippines and Cuba. In 1895 and 1896 the Cuban War of Independence and the Philippine Revolution broke out and eventually the United States became involved. The Spanish–American War was fought in the spring of 1898 and resulted in Spain losing the last of its once vast colonial empire outside of North Africa. El Desastre (the Disaster), as the war became known in Spain, gave added impetus to the Generation of ’98 who were analysing the country.
Although the period around the turn of the century was one of increasing prosperity, the 20th century brought little social peace; Spain played a minor part in the scramble for Africa, with the colonisation of Western Sahara, Spanish Morocco and Spanish Guinea. It remained neutral during World War I. The heavy losses suffered by the colonial troops in conflicts in northern Morocco against Riffians forces brought discredit to the government and undermined the monarchy.
Industrialisation, the development of railways and incipient capitalism developed in several areas of the country, particularly in Barcelona, as well as Labour movement and socialist and anarchist ideas. The 1888 Barcelona Universal Exposition and the 1870 Barcelona Labour Congress are good examples of this. In 1879, the Spanish Socialist Workers’ Party was founded. A trade union linked to this party, Unión General de Trabajadores, was founded in 1888. In the anarcho-sindicalist trend of the labour movement in Spain, Confederación Nacional del Trabajo was founded in 1910 and Federación Anarquista Ibérica in 1927.
Catalanism and Vasquism, alongside other nationalisms and regionalisms in Spain, arose in that period, being the Basque Nationalist Party formed in 1895 and Regionalist League of Catalonia in 1901.
Political corruption and repression weakened the democratic system of the constitutional monarchy of a two-parties system. The July 1909 Tragic Week events and repression exemplified the social instability of the time.
The La Canadiense strike in 1919 led to the first law limiting the working day to eight hours.
After a period of Crown-supported dictatorship from 1923 to 1931, the first elections since 1923, largely understood as a plebiscite on Monarchy, took place: the 12 April 1931 municipal elections. These gave a resounding victory to the Republican-Socialist candidacies in large cities and provincial capitals, with a majority of monarchist councillors in rural areas. The king left the country and the proclamation of the Republic on 14 April ensued, with the formation of a provisional government.
A constitution for the country was passed in October 1931 following the June 1931 Constituent general election, and a series of cabinets presided by Manuel Azaña supported by republican parties and the PSOE followed. In the election held in 1933 the right triumphed and in 1936, the left. During the Second Republic there was a great political and social upheaval, marked by a sharp radicalization of the left and the right. Instances of political violence during this period included the burning of churches, the 1932 failed coup d’état led by José Sanjurjo, the Revolution of 1934 and numerous attacks against rival political leaders. On the other hand, it is also during the Second Republic when important reforms to modernize the country were initiated: a democratic constitution, agrarian reform, restructuring of the army, political decentralization and women’s right to vote.