In the 1930s, Spanish politics were polarized at the left and right of the political spectrum. The left-wing favored class struggle, land reform, autonomy to the regions and reduction in church and monarchist power. The right-wing groups, the largest of which was CEDA, a right wing Roman Catholic coalition, held opposing views on most issues. In 1936, the left united in the Popular Front and was elected to power. However, this coalition, dominated by the centre-left, was undermined both by the revolutionary groups such as the anarchist CNT and FAI and by anti-democratic far-right groups such as the Falange and the Carlists. The political violence of previous years began to start again. There were gunfights over strikes, landless labourers began to seize land, church officials were killed and churches burnt. On the other side, right wing militias (such as the Falange) and gunmen hired by employers assassinated left wing activists. The Republican democracy never generated the consensus or mutual trust between the various political groups that it needed to function peacefully. As a result, the country slid into civil war. The right wing of the country and high ranking figures in the army began to plan a coup, and when Falangist politician José Calvo-Sotelo was shot by Republican police, they used it as a signal to act.
On 17 July 1936, General Francisco Franco led the colonial army from Morocco to attack the mainland, while another force from the north under General Sanjurjo moved south from Navarre. Military units were also mobilised elsewhere to take over government institutions. Franco's move was intended to seize power immediately, but successful resistance by Republicans in places such as Madrid, Barcelona, Valencia, the Basque country and elsewhere meant that Spain faced a prolonged civil war. Before long, much of the south and west was under the control of the Nationalists, whose regular Army of Africa was the most professional force available to either side. Both sides received foreign military aid, the Nationalists, from Nazi Germany, Fascist Italy and Portugal, the Republic from organised far-left volunteers in the International Brigades.
The Siege of the Alcázar at Toledo early in the war was a turning point, with the Nationalists winning after a long siege. The Republicans managed to hold out in Madrid, despite a Nationalist assault in November 1936, and frustrated subsequent offensives against the capital at Jarama and Guadalajara in 1937. Soon, though, the Nationalists began to erode their territory, starving Madrid and making inroads into the east. The north, including the Basque country fell in late 1937 and the Aragon front collapsed shortly afterwards. The bombing of Guernica was probably the most infamous event of the war and inspired Picasso's painting. It was used as a testing ground for the German Luftwaffe's Condor Legion. The Battle of the Ebro in July–November 1938 was the final desperate attempt by the Republicans to turn the tide. When this failed and Barcelona fell to the Nationalists in early 1939, it was clear the war was over. The remaining Republican fronts collapsed and Madrid fell in March 1939.
The war, which cost between 300,000 to 1,000,000 lives, ended with the destruction of the Republic and the accession of Francisco Franco as dictator of Spain. Franco amalgamated all the right wing parties into a reconstituted Falange and banned the left-wing and Republican parties and trade unions.
The conduct of the war was brutal on both sides, with massacres of civilians and prisoners being widespread. After the war, many thousands of Republicans were imprisoned and up to 151,000 were executed between 1939 and 1943. Many other Republicans remained in exile for the entire Franco period.