The 20th century was a period of great change in Spain. The monarchy gave way to Primo de Rivera's dictatorship and then to the Second Spanish Republic. Franco came to power after the end of the Civil War and governed in Spain through a military dictatorship until his death in 1975. Juan Carlos I, chosen by Francisco Franco to continue the dictatorship, approved the Reform to turn Spanish into a parliamentary democracy.
Alfonso XIII ascended to the throne in 1902, and reigned until the coup d'etat of Primo de Rivera in 1923. The reign of Alfonso XIII was marked by very unstable political situation, mainly motivated by his lack of respect for his role as a referee between the three powers of the state (legislative, executive and judicial). The lower social classes were also unhappy about their situation, because they didn't have a real representation in the government who would look after them; and the Rif War had caused many problems, many of which were left unresolved. This, together with the difficult situation in Catalonia, which wanted to become independent, and the arrival of Italian fascism with Mussolini at its head, gave way to the dictatorship of Primo de Rivera after the coup d'etat that took place in Madrid in 1923.
The dictatorship of Primo de Rivera lasted from 1923 to 1930. Once he was in power (with the consent of the king), he declared a state of war, and the abolishment of the Constitution and of the constitutional guarantees. Because the dictatorship was though of as a transitional government until things calmed down Primo de Rivera ceased the local authorities and the main administrative roles, and substituted them with military. In the beginning, this initiative was approved by the people due to their disappointment in the previous regime. This lasted until 1925, and after that Primo de Rivera was forced to include civilians in state positions. The administrative reform was done by Primo de Rivera and Calvo Sotelo, and it culminated in the Municipal Statute that allowed a certain autonomy that would permit the development of the municipalities, but it didn't accept the universal suffrage which was very demanded by the people.
The economic growth of Spain and the success of Primo de Rivera's policies wasn't enough for the people, who weren't happy with the dictatorship. The workers' parties began to gain popularity due to the absolute lack of good working conditions, and even those who had approved of Primo de Rivera in the beginning began to feel the effects of repression and censorship. The general unhappiness reached the army, and started the first republican uprisings. The forces behind the left wing parties signed the Pact of San Sebastián, in which they agreed to try and proclaim a Republic and put an end to the dictatorship. The economic situation in Spain was worsening quickly, and left the country unable to assume the Great Depression of 1929. Primo de Rivera was forced to step down in January of 1930 by Alfonso XIII. A succession of unable and unstable governments followed, but after the elections of 1931 and the victory of the republican parties in most of Spain, the Second Spanish Republic was proclaimed the 14th of April of 1931.
The Second Spanish Republic can be divided in two main time periods:
The second and last elections of the Second Spanish Republic took place in 1936, and resulted in the triumph of the "Popular Front", a left winged coalition formed by PSOE, Izquierda Republicana and Unión Republicana among others, and Azaña was once again named President of State. The growing tensions and unhappiness of the people gave way to the Spanish Civil War in 1936, which some historians say was also caused by the murder of Calvo Sotelo, leader of the opposition.
The Spanish Civil War spans from 1936 to 1939, and it ended with the ascent of Francisco Franco as President of Spain and the establishment of another dictatorship, that lasted until 1975. Franco's dictatorship was secured by the political and economic repression of the opposition. His economic policies were based on autarky caused by the II World War, to where Franco sent the Blue Division, a group of soldier volunteers who helped Hitler in the war against the Soviet Union. In the 50's, in the context of the Cold War, Spain's geographical position and its military dictatorship ended up becoming strategic for the United States and its European allies against the Soviet Union. Spain's alliance with the US ended with the international isolation and helped open up the economy, although it wasn't able to catch up with the rest of the European democracies.
During the 60's and 70's, the development of Spain continued, but not with equal force in all parts of Spain (the major cities like Madrid, Barcelona and Valencia were more developed, but the rest if Spain, especially the south, which suffered from a great economic crisis), which caused heavy inequalities between regions. Although the quality of life of the Spanish improved, the same can't be said for their personal and political freedom. The growing unhappiness of the people gave way to uprisings from workers and students.
Franco died on the 20th of November of 1975, and Juan Carlos I was named King of Spain. He promised to abide by the Principles of the National Movement, which were created by Franco to perpetuate the dictatorship after his death, but instead he used them to promote the Referendum for the Political Reform; the results were 94% in favor. This marked the beginning of Spain's transition towards a parliamentary democracy.