After the death of King Alfonso XII, Spain experienced political instability and conflict in the early 20th century. This led to a military dictatorship under Primo de Rivera from 1923-1930. The Second Republic then began in 1931, establishing democracy, secularism, and autonomy. However, these reforms divided Spain and led to civil war from 1936-1939, resulting in a nationalist victory under Francisco Franco, who ruled as a dictator until his death in 1975.