The answer is that elections in Catalonia, especially “general elections” in which the seats in the Spanish Parliament are chosen, have various axes, not only right vs left, but Catalanist vs Spainist, for want of better terms. The important leftist parties in Spain have local affiliates in Catalonia that are mostly seen as hewing to the centralist party line. They tend to win country-wide elections and lose local ones. The right in Catalonia, however, is divided between the local affiliate of the Spanish Popular Party—whose francoist roots make it a particularly hard sell in Catalonia—and the completely homegrown CiU, whose wildly popular leader, Jordi Pujol was president of the Catalan Parliament for 23 years between 1980 and 2003, and with these results completed the trifecta after already having triumphed in recent municipal and Catalonia-wide elections.
It seems unsurprising that Catalans would want to kick the Socialists out, but would choose to do so without running into the arms of the PP, whose party was behind the recent trampling of Catalonia's new Statute of Autonomy, as well as attacks on the successful and popular Catalan-immersive educational system.
CiU clenched the deal with a big promise: they will demand a “fiscal pact” with Madrid, and if rebuffed, will demand political independence. Catalonia currently pays some 10% more in taxes than they receive in services from the central government, and the current fiscal crisis is fueling resentment in Catalonia. Catalans see brand new schools, free highways, and high speed trains in sparsely populated areas of Spain while being forced to make substantial cuts in medical, educational, and transportation services of their own.
As Salvador Cardús put it in What Catalans Want, “We live in a situation in which we are denied the guarantee that our daily work will contribute in any way to our prosperity.”
It's important to remember that Duran i Lleida, CiU's candidate, is more unionist than separatist, despite convenient rhetoric to the contrary. Last night he said, “Catalonia is different from the rest of the country. Today, these results confirm more than ever that we are a nation.”
It will be interesting to watch these next few months.