* Ruling PP win most votes, well short of majority
* Socialists second, Podemos third, Ciudadanos fourth
* Left-wing parties gain most clout
* Split results herald weeks of deal-making (Recasts with final results, new quotes)
By Julien Toyer and Sonya Dowsett
MADRID, Dec 21 (Reuters) - A historically fragmented vote in Spanish elections on Sunday heralded weeks of talks to form a coalition government, with neither Prime Minister Mariano Rajoy's conservatives nor left-wing parties winning a clear mandate to govern.
Despite garnering the most votes, the centre-right People's Party (PP) had its worst result ever in a general election as Spaniards angered by high-level corruption cases and soaring unemployment turned away from the party in droves.
The outcome was reminiscent of a similar situation in neighbouring Portugal, where the incumbent conservatives won an October election but a socialist government backed by far left parties was ultimately sworn in.
An unexpected surge from upstart anti-austerity party Podemos, which now partly holds the key to power, is the latest example of rising populist forces in Europe at the expense of mainstream centre-right and centre-left parties.
In Spain, the fragmented vote heralded a new era of pact-making, shattering a two-party system that has dominated Spain since the 1970s and casting a pall over an economic reform programme that has helped pull the country out of recession.
"We're starting a period that will not be easy," Rajoy told cheering supporters from the balcony of the party headquarters in central Madrid. "It will be necessary to reach pacts and agreements and I will try to do this."
However, the likelihood of a PP-led coalition faded with the robust showing of Podemos who roared into third place, outpacing fellow newcomer Ciudadanos whose market-friendly policies had been seen as a natural fit for the PP.
A tie-up between the PP and Ciudadanos would yield 163 seats, far short of the 176 needed for a majority administration.
The strong results of Podemos tipped the balance to the left of the political spectrum with five left-wing parties led by the opposition Socialists and Podemos together winning 172 seats.
Such a left-wing alliance will be hard to form, however, as groups differ on economic policy and the degree of autonomy that should be awarded to the wealthy northeastern region Catalonia, home to an entrenched independence movement.
"This result confirms Spain has entered an era of political fragmentation," said Teneo Intelligence analyst Antonio Barroso. "The key question is whether there will be a coalition of parties against Rajoy."