At the very moment the United States needed its public health infrastructure the most, many local health departments had all but crumbled, proving ill-equipped to carry out basic functions let alone serve as the last line of defense against the most acute threat to the nation’s health in generations.

Epidemiologists, academics and local health officials across the country say the nation’s public health system is one of many weaknesses that continue to leave the United States poorly prepared to handle the coronavirus pandemic, which has claimed more than 180,000 lives in the country.

That system lacks financial resources. It is losing staff by the day. And its shortcomings are especially evident in the context of the Trump administration, which has taken a largely hands-off approach to virus response and left local leaders to steer their neighbors through the crisis.

Even before the pandemic struck, local public health agencies had lost almost a quarter of their overall workforce since 2008 — a reduction of almost 60,000 workers, according to national associations of health officials. The agencies’ main source of federal funding — the Centers for Disease Control and Prevention’s emergency preparedness budget — had been cut 30 percent since 2003. The Trump administration had proposed slicing even deeper.

While the country spends roughly $3.6 trillion every year on health, less than 3 percent of that spending goes to public health and prevention, according to an April analysis by the nonprofit Trust for America’s Health.

The dilapidated state of the nation’s public health infrastructure has never been a secret, exposed time and again by problems such as the opioid crisis and persistent racial disparities in health-care access and treatment. But the problems have been left to fester.

In Boone County, W.Va., the staff of one nurse and two clerks at the public health department did not have enough thermometers when the pandemic began and are working 12- to 13-hour days to keep the department functioning.

Delaware County, Pa., a heavily populated Philadelphia suburb, did not even have a public health department when the pandemic struck and had to rely on a neighbor to mount a response.

When the Southern Nevada Health District suddenly lost a grant, it could no longer extend additional resources to minority mothers.

With plunging tax receipts straining local government budgets, public health agencies confront the possibility of further cuts in an economy gutted by the coronavirus. It is happening at a time when health departments are being asked to do more than ever.

“Even before covid-19, we were at a critical juncture of needing to invest in public health infrastructure in new ways — things had been left languishing,” said Ryan Westergaard, chief medical officer and epidemiologist for the state of Wisconsin, talking about the disease caused by the novel coronavirus. “And now, on top of that, we have an impossible situation.”

According to public health expert David Himmelstein at CUNY’s Hunter College, global consensus is that, at minimum, 6 percent of a nation’s health spending should be devoted to public health efforts. The United States, he said, has never spent more than half that much.

At the same time, many countries that invest more in public health infrastructure also provide universal medical coverage that enables them to provide many common public health services as part of their main health-care-delivery system.

Compared with Canada, the United Kingdom and northern European countries, the United States — with a less generous social safety net and no universal health care — is investing less in a system that its people rely on more.

Himmelstein said that the United States has never placed much emphasis on public health spending but that the investment began to decline even further in the early 2000s. The Great Recession fueled further cuts.

Plus, the U.S. public health system relies heavily on federal grants.

“That’s the way we run much of our public health activity for local health departments. You apply to the CDC, which is the major conduit for federal funding to state and local health departments,” Himmelstein said. “You apply to them for funding for particular functions, and if you don’t get the grant, you don’t have the funding for that.”

“Why an ongoing government function should depend on episodic grants rather than consistent funding, I don’t know,” he added. “That would be like seeing that the military is going to apply for a grant for its regular ongoing activities.”

Few places were less prepared for covid-19’s arrival than Delaware County, Pa., where Republican leaders had decided they did not need a public health department at all.

County Councilwoman Monica Taylor and a group of other Democrats — running in part on the need to rebuild the county’s public health infrastructure — won last fall with a plan to establish a fully functional health department by 2021. But long-term optimism turned to short-term panic when the pandemic hit and the fifth-most-populated county in Pennsylvania had no local infrastructure to deal with it.

“I think the general population didn’t really realize we didn’t have a health department. They just kind of assumed that was one of those government agencies we had,” Taylor said. “Then the pandemic hit, and everyone was like, ‘Wait, hold on — we don’t have a health department? Why don’t we have a health department?’ ”

Taylor and other elected officials worked out a deal with neighboring Chester County in which Delaware County paid affluent Chester County’s health department to handle coronavirus operations for both counties for now.

Delaware County is an extreme example of how local public health is often perceived.

One reason health departments are so often neglected is their work focuses on prevention — of outbreaks, sexually transmitted diseases, smoking-related illnesses. Local health departments describe a frustrating cycle: The more successful they are, the less visible problems are and the less funding they receive. Often, that sets the stage for problems to explode again — as infectious diseases often do.

It has taken years for many agencies to rebuild budgets and staffing from deep cuts made during the last recession, said John Auerbach, CEO of Trust for America’s Health, who was public health commissioner in Massachusetts, as well Boston’s top public health official, and later worked at the CDC.

During the past decade, many local health departments have seen annual rounds of cuts, punctuated with one-time infusions of money following crises such as outbreaks of Zika, Ebola, measles and hepatitis. The problem with that cycle of feast or famine funding is that the short-term money quickly dries up and does nothing to address long-term preparedness.

“It’s a silly strategic approach when you think about what’s needed to protect us long term,” said Lori Freeman, CEO of the National Association of County and City Health Officials. She compared the country’s public health system to a house with deep cracks in the foundation. The emergency surges of funding are superficial repairs that leave those cracks unaddressed.

“We came into this pandemic at a severe deficit and are still without a strategic goal to build back that infrastructure. We need to learn from our mistakes,” she said.

Even in places with well-established health departments, budgetary concerns are spiraling.

A year of dealing with the coronavirus could bring even more cuts, many public health leaders said. With the economy tanking, the tax bases for cities and counties have shrunken dramatically — payroll taxes, sales taxes, city taxes. Many departments have started cutting staff. Federal grants are no sure thing.

Teryn Zmuda, chief economist for the National Association of Counties, said 80 percent of counties have reported their budget was affected in the current fiscal year because of the crisis. Prospects are even more dire for future budget periods, when the full impact of reduced tax revenue will become evident.

“Local public health is not a negotiable item in terms of providing those services to your residents,” Zmuda said.

The Southern Nevada Health District, which serves Las Vegas, receives 25 to 30 percent of its budget from county revenue, according to Fermin Leguen, the department’s chief health officer. Because Las Vegas’s behemoth tourist industry lost months of normal revenue, he expects that portion of his budget will shrink.

Even more debilitating is the idea of losing grant money, which makes up an additional 25 percent of the department’s budget. Two years ago, Leguen’s agency lost a major federal grant that funded programs for minority mothers and their children.

“We didn’t have the funds to replace that program. We had to devise an alternate program for that, but it’s not at the same level of activity,” said Leguen, who said his department is losing another federal grant allocating money to teen pregnancy prevention, and it will not be able to replace that either.

For smaller public health departments, losing a grant or a few thousand dollars of funding can debilitate more than just one program.

Julie Miller is the lone nurse at the Boone County, W.Va., health department, which has been “running on empty for a long time,” she said. It depends on grants from the federal government and money from the state.

“We didn’t have thermometers,” Miller said, noting that only because of her frugality did the department have a small stockpile of personal protective equipment when the pandemic began. “We’re a health department — why would we have anything so simple?”

She is also hoping to get enough money to hire an expert to check the county’s food and water. The woman who held that position was forced into retirement by health issues this year.

So Miller and her colleagues — a couple of clerks who come in and out to help when they can — had to cancel regularly scheduled clinic hours and limit services to ensure they could respond to the pandemic. But with few other medical facilities available, Miller knew she could not simply stop offering regular services. So she is still administering those, too.

She and her colleagues would give anything to be able to rest at home or even “to go away a little bit — to go somewhere and recharge,” Miller said. “We know that’s not possible. So I keep telling myself, Nov. 1, 2021 — that’s what keeps me going.”

Miller plans to retire then. She recently said she hopes to have the money to hire another nurse before then so she will have time to train her successor — although such jobs may become hard to fill because the profession has become a thankless endeavor.

The National Association of County and City Health Officials maintains a spreadsheet tracking departures of key health officials at the state and local level over the past few months, a number that was at three dozen and counting as of late July. Freeman, the association CEO, said she worries about public health experts leaving the field in droves in the months to come.

“They’re tired, stressed, overwhelmed and being attacked from every which way,” Freeman said.

Christine Hahn, medical director for Idaho’s division of public health and a 25-year public health veteran, has seen the state make progress in coronavirus testing and awareness. But like so many public health officials across the country taking local steps to deal with what has become a national problem, she is limited by how much government leaders say she can do and by what citizens are willing to do.

“I’ve been through SARS, the 2009 pandemic, the anthrax attacks, and of course I’m in rural Idaho, not New York City and California,” Hahn said. “But I will say this is way beyond anything I’ve ever experienced as far as stress, workload, complexity, frustration, media and public interest, individual citizens really feeling very strongly about what we’re doing and not doing.”

Many public health officials say a lack of a national message and approach to the pandemic has undermined their credibility and opened them up to criticism.

“People locally are looking to see what’s happening in other states, and we’re constantly having to talk about that and address that,” said Jennifer Vines, lead health officer in Multnomah County, Ore., home to Portland.

“I’m mindful of the credibility of our messaging as people say, ‘What about what they’re doing in this place? Why are we not doing what they’re doing?’ ”

Many health experts worry the challenges will multiply in the fall with the arrival of flu season.

If a coronavirus vaccine is made available in coming months, it will be up to public health agencies to help administer it.

“The unfolding tragedy here is we need people to see local public health officials as heroes in the same way that we laud heart surgeons and emergency room doctors,” Westergaard, the Wisconsin epidemiologist, said. “The work keeps getting higher, and they’re falling behind — and not feeling appreciated by their communities.”