While Greece haggles over every detail in an austerity plan imposed by the European Union and the International Monetary Fund, Spain has been Europe’s good student.

Even while the Socialists were still in power, Spain took the initiative in slashing mercilessly into welfare budgets and reducing salaries, vowing to get a handle on a dangerous pile of deficits and debts. The conservative prime minister elected three months ago, Mariano Rajoy, has pursued the cutback campaign even more vigorously, raising taxes and redoing labor laws.

Spain’s drastic belt-tightening has moved government accounts in the right direction for the first time since the European financial crisis erupted last year. But in so doing, it has braked the economy into recession, accelerating a wave of firings and darkening the horizon for millions of workers.

In most of the 17 countries using the E.U. common currency, the euro, this has become the no-win choice leaders have had to make: balance budgets but forsake growth and jobs. Although they regularly promise to stimulate their economies — particularly France’s President Nicolas Sarkozy, who faces elections in the spring — the deep spending cuts required to carve down deficits and public debts have, in fact, strangled economic activity.

With the exception of Germany, zero growth or even recession has been predicted across most of the continent for the rest of the year and perhaps beyond. As a result, tax receipts needed to finance government action are declining and, in the saddest human toll, unemployment has risen to new heights.

Rajoy warned last week that unemployment in Spain — already Europe’s highest at nearly 23 percent — is likely to climb still higher before the year is out. The prospect for young people, those 24 and younger, among whom unemployment has reached 46 percent, is particularly bleak.

“This year is going to be bad,” Rajoy told Parliament. “We have to say so to the Spanish people.”

That was unwelcome but not unexpected news for Carlos Burillo as he marched around Madrid’s Liberty Square on a cold winter evening in a subdued demonstration by labor unions. The 33-year-old physical education teacher found an interim job in a junior high school for this term, but as of September he faces a new round of unemployment unless he can find someplace that is hiring.

“This crisis is all over Europe,” he said. “We hope it only lasts for three years or so.”

Unemployed at 59

One of those unemployed people, Martin, spends a lot of time walking. He said he walks to and fro in Madrid’s gritty Vallecas neighborhood, walking to go nowhere, walking just to pass the time of day.

There is a daily one-hour computer course organized by the Madrid unemployment office, he said, averting his gaze and declining to give his family name for publication. But for the rest of the time, walking is all he has to do.

Martin, 59, was not always a walker. During Spain’s boom years, he was a construction worker who specialized in taking topography readings for the new roads and streets that were being laid everywhere at the time. Then two years ago, it all went bust. The suburban housing developments went broke. The company he worked for had no more projects.

Martin was suddenly unemployed for the first time in his life.

A lot of his friends and colleagues faced the same problem, he recalled. Many left Spain in search of new jobs. Some went to South America, he said, and others tried Eastern Europe.

After a long dry period, Martin found another job, a tunnel that was being built by the Madrid city hall and a small company that had snagged the contract. It was only half time, but better than nothing. But after a little over a year, that, too, stopped. Two months ago, Martin again joined the unemployment rolls.

“It was just before Christmas,” he recalled. “Nobody said thanks, sorry, nothing. It was my Christmas present.”

Martin said that, because of his long years of working, he gets full unemployment benefits of about $1,300 a month. But that runs out after two years on the rolls, meaning he faces a reduction to $545 unless he can find a new job.

“I hope I don’t get to that point,” he said, smiling. “But if even those who are only 40 years old can’t find jobs, how do you expect me to find one at my age?”

To help the household, Martin’s wife has started taking work cleaning houses. It is not much, but it helps. The couple’s only child, a son, is on his own so they get along on what they have.

But the idleness grinds away at him. The daily computer course. Frequent visits to the Vallecas branch of the city unemployment office. But mostly walking, walking past boarded-up shops and shuttered cafes, walking to the park benches where other unemployed men gather to gossip in the afternoon.

‘Our problem is obedience’

For Martin, Spain’s woes are due in large measure to profligate spending by Socialists under former prime minister Jose Luis Zapatero. Zapatero did not realize the severity of the economic crisis as it descended on Europe in 2008, he said, and failed to clamp down on corruption that infected the central government and especially the autonomous governments in Catalonia and other regions.

“The money, it all went into their pockets,” he said.

For others, the problem is that Spain’s leaders are too willing to listen to Germany, or the European Union, or the International Monetary Fund — all demanding budget discipline to get deficits and debts under control.

“That’s the problem,” said Jordi Somani, who lost his job as a cellphone technician two years ago and has found nothing to replace it. “We no longer depend on our own government, but on Germany or the IMF.”

El Pais newspaper, traditionally sympathetic to the Socialists, reported this week on Rajoy’s effort to get E.U. approval for his labor reform plans, including a possible reduction in retirement benefits. “But the Germans wanted more,” the report said. “A lot more.”

A poster pasted up by a far-leftist group in Vallecas says Spaniards have been too complacent, suggesting that they rise up against the system.

“Not work, nor the crisis, nor unemployment, not retirement, not mortgages nor labor reform,” it declared over a drawing of a worker with a chain around his neck. “Our problem is obedience.”

Thousands of young people who gathered in Madrid’s Plaza de Sol last spring felt the same way. “No to the crisis,” they shouted.

The protesters rejected both of Spain’s main political parties, the Popular Party and the Socialist Workers Party, and complained that traditional labor unions had become too encrusted with the government to represent the workers faithfully. Part of a worldwide uprising by young people, the Plaza del Sol movement received broad coverage in the Spanish and other European press as a sign of the times.

The square has been empty for months, however, and Rajoy’s conservative Popular Party easily beat the Socialists in elections in November on a promise of still more austerity, still more cutbacks and still more layoffs.

One of those who camped in the square, Carlos Sepulveda, said the youths keep in touch through meetings and Internet conversations, even if they no longer gather on the square. They plan another demonstration in May, he said, that they hope will be coordinated with others around the world.

The point of the “indignados” in the square, he said, was not to affect the elections or reform political parties. It was rather to shout out that the system was not working and that new ideas must be brought to bear on the economic crisis.

“We were tired of politics,” declared the 30-year-old part-time teacher’s assistant, rolling a cigarette at a heated sidewalk cafe. “What we accomplished was intangible. What we did was put into the political debate questions that had not existed before.”

For Sepulveda and the indignados, Spain’s financial crisis occurred when banks faced the danger of insolvency because a real estate bubble burst, leaving them with billions in toxic loans. To save the banks, he said, the government turned over billions of dollars in rescue funds, racking up a deficit and assuming an unbearable debt that now has to be reduced.

“You can’t tell me there’s no money,” he said, noting the billions funneled to failing banks. “There’s money. But where is the money?”