By Niki Kitsantonis, The New York Times

ATHENS — The Greek government has made a range of painful cuts to salaries, pensions and jobs for public workers over the last four years, saying they were needed to satisfy the demands of the international creditors that bailed the country out. But the Greeks hurt by those steps, and the nation’s courts, have a different idea.

Steadily, citizens groups — including police officers, university professors, cleaning workers and judges themselves — have challenged the cuts as illegal or unconstitutional. And in case after case, Greek courts have agreed, presenting a nearly existential question for the government: Can it actually shrink the state?

The mounting pile of judgments has now become a serious obstacle to the austerity drive of Prime Minister Antonis Samaras, with the International Monetary Fund warning this week that the “adverse court rulings” threaten to undo the country’s reforms, which its creditors are scheduled to begin reviewing in July.

Coming just as an embattled Mr. Samaras tries to convince citizens and investors that Greece is finally turning a corner, the rulings threaten to punch a gaping hole in the finances of the government. Besides potentially having to reverse many of its public-sector layoffs, Greece could be obliged to scramble for one billion euros, about $1.35 billion, in back pay.

“They’re bigger than us, but we’re angrier,” said Despina Kostopoulou, 53, who worked at the Finance Ministry as a cleaning woman for 22 years before she was laid off last fall. In May, a court ruled that she and 396 of her fellow workers were unfairly dismissed. Since then, she has been sleeping in a tent outside the ministry’s offices, brandishing mops and demanding, along with her co-workers, that the ministry rehire them.

The David-and-Goliath-style standoff has turned the cleaning women into unlikely symbols of resistance to the austerity measures that Mr. Samaras insists have gradually allowed Greece to resume control of its finances, return to bond markets and report a primary surplus — a budget in the black before debt payments — of about $2 billion.

But those same steps have also slashed Greek incomes by a third, driven unemployment to around 27 percent and left the population fuming.

Other countries that have enforced austerity programs have witnessed similar popular challenges and clashes between the government and the judiciary. In Portugal, which recently emerged from its foreign bailout, a top court rejected cuts to salaries and pensions in May, prompting the government to scramble for alternative measures amid feverish speculation about tax increases.

Some of the rulings that have gone against the Greek government have yet to be officially announced or are being appealed. An initial appeal of the decision on the cleaning workers was rejected in May; a second appeal was upheld in a ruling on Thursday by the Supreme Court. A final decision is now expected in September, when many expect that the cleaning workers will be vindicated.

Many of the rulings against the government may ultimately be upheld by Greece’s highest courts, experts said. That would leave the government at a legal dead end and with little other choice, if it is to satisfy its creditors, than to defy the rulings or look for cuts in other places. Either option could further stoke public anger and spark fresh legal appeals by other groups of citizens.

“This is an avalanche that’s started,” said Jens Bastian, an economic consultant and former official on the European Commission’s task force for Greece. “It’s not going to stop.”

Already, the number of challenges to the government’s austerity efforts is growing, and its losses are accumulating.

In January, Greece’s top administrative court, the Council of State, deemed that the government’s cuts to the wages of police and armed forces employees violated the Constitution. In February, the same court ruled that a tax on benefits for university staff members and cuts to civil servants’ pensions were illegal. The same month, Greek Supreme Court judges found that a property tax introduced in 2011 as an emergency measure and later extended was unconstitutional. Another court rejected cuts to the salaries of state hospital doctors, university professors and, unsurprisingly, judges.

The country’s faltering privatization drive is also at risk. In May, the Council of State blocked the sale of the state’s majority stake in the Athens water company, with a current stock market value of around $813 million, out of concern that water quality could deteriorate under private control. The move raised questions about whether the government can meet a target to sell off $2 billion worth of assets in 2014.

According to analysts, the decisions could upend Mr. Samaras’s progress in putting the economy back on track. Achieving a budget surplus was a precondition for the start of talks in the fall among Greece and its euro zone partners on lightening Greece’s debt load.

In its report on Greece this week, the I.M.F. expressed concern about Greece’s “very high” debt, which stands at about 175 percent of economic output, and said a “dramatic improvement” in the efficiency of its public sector was still needed to avoid further austerity measures. If the courts roll back the government’s reforms, compensating measures will be necessary, it said.

In any case, European officials recently repeated their view that Greece is likely to need a third, much smaller, bailout in addition to the two loan agreements worth a total of $325 billion it has already been granted since 2010 by its so-called troika of creditors — the European Commission, the European Central Bank and the I.M.F.

“The rulings have immediate implications for Greece’s fiscal strategy and revenue projections, which must be revised,” Mr. Bastian said.

“Privatization targets are constantly being revised downward and tax collection is difficult, as people can’t pay,” he added, referring to public debts to the state that have topped $89 billion and are rising by $1.35 billion every month.

The string of legal decisions has wrought political damage, too, on a government that has been left wobbling from the victory of the leftist opposition party Syriza in European Parliament elections last month. Mr. Samaras carried out a thorough cabinet shuffle on Monday, installing Gikas Hardouvelis, a respected economist and former government adviser, as finance minister in an attempt to breathe new life into an administration tainted by government austerity programs.

The resilience of the cleaning workers at the Finance Ministry has proved to be an embarrassment, and may signal complications to come.

A ministry official, who spoke on the condition of anonymity, said a reversal of the cleaners’ dismissals could gut the “central tenet” of the government’s plans to trim the public sector — its “mobility scheme” — that began last year. The measure requires placing 25,000 civil servants on reduced pay for eight months before dismissing them if they cannot find another public-sector job.

That plan is in addition to the layoffs of 15,000 public-sector workers, 11,000 of whom are supposed to be let go this year. Short of dismissing the cleaners, “the alternative was to dismiss tax collectors,” the official said, noting that a private firm is doing the cleaners’ job for a third of the cost.

Experts say the government’s imposition of these measures will probably result in more rulings in favor of public-sector workers, presenting it with the difficult choice of defying Greek courts to placate its foreign creditors or giving ammunition to austerity protesters.

“The government is in a state of emergency, so it is violating the Constitution,” said Aristides Hatzis, a professor of legal theory at the University of Athens. But the courts will continue to block measures that violate laws, he said, adding: “The judges are doing their job. The demands of the troika are not their problem.”

Watch also this