MADRID — The staggering rate of coronavirus infections in Spain — where nearly 5,000 people have died since the start of the outbreak — has trained a spotlight on a health care system left badly wounded after years of austerity.

Like elsewhere in Europe, the crisis situation has forced hospitals and doctors to reach to extremes to cope with the surge of critically ill patients: Hospitals have called retired doctors under 70 to the front lines and recruited medical students to do administrative work; in Madrid, a massive conference center has become the country’s largest hospital and an ice rink has been repurposed as a morgue.

As politicians of all stripes line up to heap praise on the efforts and sacrifices being made by Spanish health workers, many argue that the excessive pressure on hospitals is at least partly a result of painful austerity measures that have left the country ill-equipped to deal with an epidemic.

“It makes no sense to take refuge in familiar claims, such as that the health care system is exemplary, as [Prime Minister Pedro] Sánchez insists,” Contexto, an online publication, warned in an editorial. “It’s a sad reminder of the comments by [Socialist Prime Minister José Luis Rodríguez] Zapatero at the start of the economic crisis, when he said the Spanish financial system was ‘one of the most solid in the world.’”

Many in Spain consider the health care system as a flagship of the country’s modernity: Free at the point of use, it is highly decentralized, with each of the country’s 17 regions controlling how their health care is run and, to an extent, how well-funded it is.

The austerity measures have also led to a number of shortages, specifically a decline in the number of hospital beds and a rise in temporary contracts for doctors and nurses.

And a decade ago, there was truth to Sánchez’s claim that the system is “robust.” During the Spanish boom times ahead of the financial crisis, the country’s spending on health care was close to the EU average.

That changed in 2011, as the economy spiraled downward and a newly elected conservative Prime Minister Mariano Rajoy embarked on a program of heavy spending cuts. He started by slashing a combined €10 billion from the health and education budgets and kept up an austerity program for much of his tenure, which ended in 2018.

Investment in the health care sector has dropped from 6.8 percent of GDP in 2009 to 5.9 percent in the government’s most recent draft budget — far below the current EU average spending of 7.5 percent of GDP.

As a result of the cuts, a “growing number of newly trained doctors were unemployed or migrating to other countries,” an EU report noted last year.

The austerity measures have also led to a number of shortages, specifically a decline in the number of hospital beds and a rise in temporary contracts for doctors and nurses, the report said.

Spending in health care has ticked back up since the austerity eased, but investment levels still fall short of what’s needed, said José Félix Hoyo, an ER doctor in Móstoles, near Madrid, and the president of the Spanish branch of Médecins du Monde.

A wave of privatizations in the sector under the regional wings of Rajoy’s conservative Popular Party (PP) have further undermined Spain’s ability to handle a pandemic on the scale of the current crisis, Hoyo warned.

“What happened in Spain was that this trend [of privatization], which was very small, grew in our health care sector in the wake of the economic crisis,” he said. “And when it comes to coordinating in a uniform way the management of an epidemic, that creates an obstacle.”

The Madrid region, which arguably saw the heaviest wave of privatizations, is now under enormous strain given that it is also the epicenter of the country’s coronavirus outbreak.

The accusations that Rajoy’s austerity measures have left the country unprepared for the current crisis doesn’t sit well with members of the PP. Earlier this week, Rajoy’s successor as party leader, Pablo Casado, roundly denied that his party had slashed health care spending and described the Spanish system as “the best in Europe.”

The denials have riled members of Podemos, the junior coalition partner in the new leftist government, whose leader, Pablo Iglesias, is known as a prominent critic of austerity and health care privatizations.

Now, as one of four deputy prime ministers, he and his party colleagues are having to fight a pandemic with a health care system they say has been hollowed by out by the neoliberal orthodoxy of the previous government.

When Sandra Ortega, heiress to the clothing retail empire Inditex, donated 1 million medical facemasks to help fight the spread of the virus, the party had to bite its tongue despite attacking the company for using cheap foreign labor in the past.

Podemos’ input in Spain’s response to the crisis is arguably already evident in the €200 billion package of measures Sánchez has announced to help keep the economy afloat. The party reportedly pushed hard for an expansive approach as the measures were being drawn up.

As the crisis deepens, the disparity between the efforts of health care professionals working around the clock and the system in which they’re operating is likely to become increasingly stark.

“Every day we go out on our balconies and clap [for the health care workers], and it’s great,” said Manuel Franco, a professor of Public Health at Alcalá de Henares University and Johns Hopkins University.

Like in countries across Europe, the nightly show of appreciation has become a ritual in Spain.

“But we should not forget that we need more money, more investment, we need to take good care of these [professionals],” Franco added. “They need better jobs, better equipment, we need better technicians, better data management and research. Hopefully that is something that will come out of this crisis.”