The country has since December 2015 been suffering chronic political instability because of an increasingly fragmented political landscape.
Here are some key dates:
Two-party hegemony shatters
Since the early 1980s, power in Spain had alternated without interruption between the socialists and the conservative Popular Party (PP). But December 20, 2015 put an end to that when two new parties, centre-right Ciudadanos and far-left Podemos, entered parliament for the first time.
Prime Minister Mariano Rajoy's PP won the most seats but lost its absolute majority in Spain's 350-seat parliament and was not able to cobble together a governing coalition.
Pedro Sanchez's socialists, which came in second but also lost ground, reached an agreement with Ciudadanos but this too was not enough to form a government.
Due to the political impasse, fresh elections were held on June 26, 2016. The PP gained ground but still fell short of an absolute majority and political paralysis persisted.
Rajoy sworn in for second term
Rajoy was finally sworn in for a second term as prime minister on October 29, 2016, putting an end to a 10-month spell without a government. That was because Ciudadanos voted for him in a confidence vote and the socialists abstained.
Weeks earlier, the socialists ousted their leader Pedro Sanchez who had steadfastly refused to back Rajoy's attempts to form a government.
Rajoy's minority government managed to pass its budget in 2017 and 2018 by making generous concessions to a Basque nationalist party and regional parties from Spain's Canary Islands.
Sanchez ousts Rajoy
Sanchez, who made a stunning political comeback after being ousted, winning his party's primaries in May 2017, became prime minister after ousting Rajoy in a no-confidence motion in parliament on June 1, 2018. He had tabled that motion after the ruling PP was found guilty of benefiting from illegal funds in a massive graft trial.
Rajoy was the first prime minister in Spain's modern democratic history to be ousted by parliament after losing a no-confidence vote.
Sanchez won the vote with the support of a hodgepodge of different formations, including Podemos, two Catalan separatist parties and a Basque nationaliRead More – Source