When Prime Minister Jose Luis Rodriguez Zapatero took power seven years ago, he and his Socialist Workers’ Party set out to perfect the welfare state in Spain. The goal was to equal— or even surpass — lavish social protections that have long been the rule for Spain’s Western European neighbors.

True to his Socialist principles and riding an economic boom, Zapatero raised the minimum wage and extended health insurance to cover everything from sniffles to sex changes. He made scholarships available to all. Young adults got rent subsidies called “emancipation” money. Mothers got $3,500 for the birth of a child, toddlers attended free nurseries and the elderly got stipends for nursing care.

How times have changed. With a U.S.-style real estate bubble having burst and the 2008 global economic crisis having unfurled like a tsunami from Wall Street to Plaza de Espana, Zapatero’s main concern in his second term has become hacking away at government spending to preserve Spain’s credit rating. The icon of socialism recently concluded a pact with labor unions and business leaders to freeze pensions, push back the retirement age from 65 to 67, trim union bargaining rights, cut civil servants’ pay by 5 percent (including his own) and suspend the childbirth bonus. The alternative, he warned, was bankruptcy.

“We are going to have to do this whatever it costs,” he declared, “and whatever it costs me.”

Cost him it did. Faced with a dramatic decline in opinion polls, Zapatero announced last month that he will not seek a third term, hoping his party can find another candidate less contaminated by the rightward shift he was forced to impose on a nominally Socialist government. But in protests ahead of local elections Sunday, demonstrators have expressed their continuing frustration with the Socialists and the austerity measures. Tens of thousands turned out Saturday despite a ban on political activity before the vote.

Spain has not been alone in making such agonizing choices. Across Western Europe, long-cherished social welfare programs have come under the scalpel in recent months as the continent’s governments seek to dig out from under deficits and debts pushed to dangerously high levels by the 2008-09 financial meltdown.

For conservative governments, the squeeze has come naturally. After heavy government outlays to rescue banks and keep economies percolating in 2008 and 2009, President Nicolas Sarkozy in France, Prime Minister David Cameron in Britain and Chancellor Angela Merkel in Germany have made fiscal discipline their political battle cry, faithfully echoed by the European Union bureaucracy in Brussels.

But in Spain, the trimming has been especially painful, because it is being carried out by a Socialist government whose ideology, leadership and support base all cry out for unbridled welfare spending and condemn the financial markets as a lair of capitalist gnomes. Although Zapatero and his lieutenants have defended the switch as unavoidable if Madrid is to remain solvent, many who voted Socialist in 2004 and in 2008 have detected the smell of treason.

Labor unions that usually back the Socialists called a general strike in September to denounce the new policies as unfair. The large protests, although peaceful, dramatized a broad unease, particularly among the millions of union strikers who also belong to the Socialist Workers’ Party — and thus demonstrating against their own champions.

“It is a Socialist government, but they are implementing the same policies as Sarkozy in France, Merkel in Germany and Cameron in Britain,” said Fernando Lezcano, a spokesman for the Workers’ Commissions labor union.“This directly affects the welfare state.”

Last week’s demonstrators, mostly young activists spurred into action by Internet appeals, seemed to view the unions as just another part of a Socialist establishment that had let them down. “Let those who caused the crisis pay the bill,” read one of the signs held aloft amid thousands of protesters marching through Madrid.

Spain’s disappointed

Manuel Garcia Jimenez has joined the ranks of Spain’s disappointed.

A faithful Socialist supporter, he voted for Zapatero in 2004, eager to end the conservative Popular Party’s eight-year reign, and again in 2008, delighted with the welfare state Zapatero seemed to be constructing during his first four-year term. With a son about to attend university, he particularly appreciated the government’s decision to make scholarships available to anyone in need.

Now, however, Garcia has begun to wonder whether his support was misplaced, having seen his salary cut by 20.75 percent. A 52-year-old midlevel official in the Housing Ministry, he was one of Spain’s 2.5 million public employees who beginning in June saw their paycheck shrink as part of Zapatero’s drastic budget cuts.

The slash cost Garcia about $210 a month, he said. To make matters worse, Garcia’s wife, also a public employee, was faced with a similar cut. Although the government portrayed the cuts as temporary, there was no time limit in the decree that made them official.

“It’s not just temporary,” Garcia lamented in an interview. “It’s fixed, and it will be hard to get back.”

Garcia, nattily dressed in a boldly striped shirt and a blue blazer, emphasized that his family will not go hungry or lose its home because of the salary cuts. The effects will be peripheral, he said, saying the family might struggle to add to its savings and have to cut its annual vacation from two weeks to one.

But to resort to cutting government workers’ salaries, he said, was something of a breach of trust. “There were other ways to save money,” he said. “Of course, this is an easy way; the first step is always to think of cutting back on civil servants.”

Then there was the way it was handled. Rumors flew for weeks that something was up as Zapatero struggled to reduce government deficits and credit agencies warned they might have to downgrade Spain’s rating. But the government said nothing until a decree became available on the Internet. People in Garcia’s office and thousands of other government buildings around the country gathered around their computer terminals to get the news — unexpectedly bad, it turned out.

“Nobody had thought there would be a cut, and especially with the Socialist Party in power,” he recalled. “But they are governing according to what the [financial] markets say.”

The question now, he added, is whether to make Zapatero’s Socialists pay at the polls in elections scheduled for next year, even though the prime minister has taken himself out of the running and the conservative opposition’s Popular Party is not to his liking.

“I’m reflecting on it,” Garcia said.

Inevitable responses

It rapidly becomes clear that something unusual has occurred in Spain when the country’s main business organization endorses the Socialist government’s recent policies and the country’s main labor unions condemn them.

For Juan Rosell, who heads the Spanish Confederation of Business Organizations, Zapatero’s moves were inevitable responses to a swift expansion of government debt that had generated finger-wagging from credit agencies and driven up the interest rates Spain must pay to get buyers for its bonds. The $950 billion deficit had become 64 percent of gross domestic product, and Economy Minister Elena Salgado predicted Madrid would owe $38 billion in interest payments this year.

“There is no other alternative,” Rosell said. “If we continue this tendency, the end of the road is bankruptcy.

“If you are captain of the boat,” he said of Zapatero, “it doesn’t matter what you thought in the past. When the wave is at 10 meters high, you have no alternative.”

Part of the problem, but also part of the solution, he said, is the fact that Spain began building its welfare state only in the 1980s, when the country launched on a two-decade economic boom that spread prosperity and brought in seemingly limitless tax revenues. As a result, many of the programs are still new and can be downgraded without shocking the country’s 47 million inhabitants, he explained.

In addition, he said, Zapatero’s resort to budget-cutting, forced on him by a deficit spinning out of control, was part of a growing trend in Western Europe that has left-wing political parties slipping rightward toward the center in response to economic pressures from the global crisis that traditional ideology can no longer address.

But senior officials in Zapatero’s government insisted they are not abandoning their ideology, only calling a timeout while they sort out the deficit problem enough to keep credit ratings at a respectable level and avoid the fate of Greece or Ireland. “We have been faithful to what we believe in,” said Maria Luz Rodriguez, the deputy employment minister.

Mario Bedera, the deputy education minister, said the cutbacks were designed not to end Spain’s welfare programs but to contain spending enough to preserve them for future years.“We have had to go against principles that we had always defended,” he explained, “but in a way that will preserve the welfare state.”

Scholarships continue, he said, and Rodriguez noted that 80 percent of the country’s 4.3 million unemployed still get benefits, a protection that costs more than $40 billion a year and is on a level never before enjoyed in Spain.

The unemployment rate, which has ballooned above 21 percent and is still rising, was in large measure a fallout of the bust in an overleveraged housing market that employed 2 million workers. But it also arose as a result of the squeeze on government investment and a policy of not replacing many public-employee retirees.

Octavio Granado, the deputy minister for social security, expressed the party’s hope that government finances will return to better health in the coming months if the economy picks up as forecast, allowing a return to freer spending for the welfare programs that he has had to shrink.

“This is not for always,” he promised.