On 28 January 1930 the military dictatorship of General
Miguel Primo de Rivera (who had been in power since September 1923) was overthrown.
 This led various republican factions from a wide variety of backgrounds (including old conservatives, socialists and Catalan nationalists) to join forces.
Pact of San Sebastián was the key to the transition from monarchy to republic. Republicans of all tendencies were committed to the Pact of San Sebastian in overthrowing the monarchy and establishing a republic. The restoration of the royal Bourbons was rejected by large sectors of the populace who vehemently opposed the King. The pact, signed by representatives of the main Republican forces, allowed a joint anti-monarchy political campaign.
12 April 1931 municipal elections led to a landslide victory for republicans.
 Two days later, the Second Republic was proclaimed, and King
Alfonso XIII went into exile.
 The king's departure led to a provisional government of the young republic under
Niceto Alcalá-Zamora. Catholic churches and establishments in cities like
Sevilla were set ablaze on 11 May.
 In June 1931 a
Constituent Cortes was elected to draft a new constitution, which came into force in December.
The new constitution established
freedom of speech and
freedom of association, extended
suffrage to women in 1933, allowed divorce, and stripped the Spanish nobility of any special legal status. It also effectively disestablished the
Roman Catholic Church, but the disestablishment was somewhat reversed by the Cortes that same year. Its controversial articles 26 and 27 imposed stringent controls on Church property and barred religious orders from the ranks of educators.
 Scholars have described the constitution as hostile to religion, with one scholar characterising it as one of the most hostile of the 20th century.
José Ortega y Gasset stated, "the article in which the Constitution legislates the actions of the Church seems highly improper to me."
Pope Pius XI condemned the Spanish government's deprivation of the
civil liberties of Catholics in the
The legislative branch was changed to a single chamber called the
Congress of Deputies. The constitution established legal procedures for the
nationalisation of public services and land, banks, and railways. The constitution provided generally accorded civil liberties and representation.
Catholic churches in major cities were again subject to arson in 1932, and a revolutionary strike action was seen in
Málaga the same year.
 A Catholic church in
Zaragoza was burnt down in 1933, and the cathedral in
Oviedo was destroyed by flames in 1934.
 The church of San Lorenzo in
Gijon was also set ablaze in the same year. The church of San Juan in
Albacete was torched three months prior to the onset of the civil war, in March 1936.
The 1931 Constitution was formally effective from 1931 until 1939. In the summer of 1936, after the outbreak of the
Spanish Civil War, it became largely irrelevant after the authority of the Republic was superseded in many places by revolutionary socialists and anarchists on one side, and fascists on the other.
The Republican Constitution also changed the country's national symbols. The
Himno de Riego was established as the national anthem, and the
Tricolor, with three horizontal red-yellow-purple fields, became the new flag of Spain. Under the new Constitution, all of Spain's regions had the right to
Catalonia (1932), the
Galicia (although the Galician Statute of Autonomy couldn't come into effect due to the war) exercised this right, with
Valencia, engaged in negotiations with the government before the outbreak of the Civil War. The Constitution guaranteed a wide range of civil liberties, but it opposed key beliefs of the conservative right, which was very rooted in rural areas, and desires of the hierarchy of the Roman Catholic Church, which was stripped of schools and public subsidies.