MADRID — Underlining the rising fragmentation of Spanish politics, two left-wing politicians appeared poised to take charge of the city halls in Madrid and Barcelona, Spain’s two largest cities, according to the preliminary results of Spanish regional and municipal elections on Sunday.

The elections, however, failed to produce the kind of clear-cut winner of four years ago, when the conservative Popular Party swept to power as voters punished the Socialists for sinking Spain into an economic crisis. Instead, Sunday’s vote is likely to be followed by tense coalition-building negotiations in Madrid as well as across much of the rest of Spain.

The elections were seen as a bellwether for the governing Popular Party and Prime Minister Mariano Rajoy’s own chances of winning general elections later this year.

Image Pablo Iglesias, the national leader of Podemos, a far-left party, which made gains in Sunday’s regional and local elections. Credit... Andrea Comas/Reuters

While the Popular Party won the most votes, according to preliminary results, it was set to lose its parliamentary majorities in most, if not all, of the country’s provinces. That setback raises the likelihood that left-leaning parties will join forces in the coming weeks to remove the Popular Party and form coalition governments.