Spain announced snap polls on Monday after the left-wing coalition government led by Prime Minister Pedro Sanchez suffered heavy losses in the local elections.
Sanchez had said on numerous occasions that he wanted to see out a full term in office and that elections would take place in December, near the end of his rotating presidency of the European Union, which begins on July 1.
It is highly unusual for a Spanish government to call a snap ballot after a poor performance in a regional vote and his thinking behind bringing forward the national election to July 23 was unclear.
"Although yesterday's elections had a local and regional scope, the meaning of the vote conveys a message that goes beyond that," Sanchez said in a televised speech. "I believe it is necessary to respond and submit our democratic mandate to the will of the people."
Sanchez's Socialists (PSOE) and their far-left junior ally Podemos both lost ground Sunday, while the mainstream conservative People's Party (PP) and far-right party Vox performed better than expected.
The results indicate that the PP and the anti-immigrant and anti-separatist Vox could unseat Sanchez and his Socialist Workers' Party (PSOE) if they replicated that performance at the national parliamentary level.
On Sunday, the PP potentially took as many as eight regional governments from the Socialists, depending on how successful the opposition party is in negotiating alliances with Vox.
Vox leader Santiago Abascal said the party was "here to stay."
It was "here to be decisive in the construction of the alternative Spain needs," he said in a speech early Monday, adding he had not yet spoken to PP leader Alberto Nunez Feijoo.
The Socialists' main setbacks came in the Valencia, Aragon and Balearic Island regions, as well as in one of their most important fiefdoms, the southwestern region of Extremadura.
In the populous Madrid region, PP's local leader Isabel Diaz Ayuso won a majority.
In big cities Valencia and Seville, where mayors were also elected, the count turned in favor of the PP, which also won an absolute majority in urban Madrid.
Barcelona was an outlier among big cities, with a pro-independence party winning, though by such a narrow margin that it will need an agreement with the Socialists to unseat the current mayor, far-left Ada Colau.
Podemos lost ground all over Spain, further weakening Sanchez's position.
Sunday's votes in 12 of Spain's 17 regions showed a return to two-party dominance by the PSOE and PP after a decade of greater involvement by smaller parties such as Podemos and centrist Ciudadanos.
Vox was formed in 2013 and came third in the last national election.