After years of heady spending, the budget cuts announced by Mayor Eric Adams last week hit New York City like a punch to the gut: Most libraries would be closed on Sundays. The expansion of the city’s signature prekindergarten program would be delayed. So would efforts to improve New York’s notoriously dirty streets and keep rats at bay. The city’s police force would be pared down in coming years.

Fiscal reality has caught up with a stunned city. The brutal cuts come as Mr. Adams scrambles to fill a $7 billion budget deficit in the next year. The Citizens Budget Commission, a nonpartisan watchdog group, estimates that the budget gap could be significantly higher, closer to $10.6 billion. New Yorkers may want to brace themselves. Much deeper cuts to city services could be ahead.

How did the nation’s largest city get into this fix? Over the past decade, city government grew significantly, as did the size of its budget. Former Mayor Bill de Blasio hired tens of thousands of workers, expanding government services after years of relative austerity under former Mayor Michael Bloomberg during the Great Recession. Some of this spending went to important investments, like creating the city’s free prekindergarten program. Other funds were put to far more questionable use, like a disastrous $1 billion mental health initiative that never got off the ground. Mr. Bloomberg had also left office with unsettled labor contracts in the city’s municipal work force. Mr. de Blasio settled them, giving the workers significant raises.

The heavy spending far outpaced inflation but was made sustainable, for a time, by a flood of revenues that poured into City Hall from Wall Street, high income taxes and tourism, which boomed. Then the pandemic hit, bringing the economy to a standstill. Federal Covid relief kept the city going, but over the past year those funds began to dry up, and the city’s economy didn’t recover as quickly from the pandemic as other regions did. At the same time, thousands of migrants began arriving at the city’s doorstep in need of shelter.

The crisis has been building for years. From time to time over the past decade, the city’s mayors and City Council leaders would put away money in a rainy-day fund, citing budget deficits in faraway years. Modest cuts were made here and there. But mostly, the spending continued. By this year, the portion of the budget funded by the city, rather than the state or federal government, had grown by $21 billion since fiscal year 2017, or 35 percent, according to the Citizens Budget Commission. Even adjusted for inflation, the budget during that period increased by a whopping $7.2 billion, or 10 percent.

The lack of fiscal discipline, particularly under Mr. de Blasio, was wildly irresponsible. And now Mr. Adams is being forced to make the hard decisions.

New York mayors regularly overstate the size of deficits while underestimating revenue. The tradition is politically useful, helping mayors slash programs they don’t like, drum up support for those they do and test the public’s tolerance for certain cuts over others. Some New Yorkers are skeptical, for example, that Mr. Adams’s proposed cuts to the police department would ever really take place.

What is all too certain is that, unlike in previous years, the budget gaps are immediate and large. Across New York City, officials and independent budget experts are scouring the nearly $113 billion budget, hunting for savings that will preserve the most essential programs. This is a vital exercise.

The City Council has an important role to play here by pushing the mayor to get serious about transparency around the budget, too. Already, its efforts have led to questions about the Adams administration’s financial management of the migrant crisis so far. In one itemized report to the City Council, for instance, the Adams administration said it spent $538 million on “services and supplies.” For half a billion dollars in taxpayer money, the Adams administration should be able to detail what those expenses really are.

The council speaker, Adrienne Adams, and the finance chair, Justin Brannan, called Mr. Adams’s cuts “too blunt” and said the administration could find much needed savings by using nonprofit groups to provide services to migrants instead of private contractors. That is admittedly a heavy lift, especially in a city with a housing crisis. But with basic services on the line in New York, it’s worth it.

There are some other promising, smart ideas as well. For instance, Brad Lander, the city’s comptroller, has pointed to about $1.5 billion in annual claims against the city as one area for reform. About $139 million of those claims come from car accidents with city vehicles. But while many of these ideas will yield savings in the long term, they won’t necessarily help New York out of its current crisis. After years of putting off the inevitable, the time for painful cuts has arrived.

So far, no one has more clearly articulated the danger of these cuts than the rapper and former New Yorker Cardi B. “What’s going to happen to my nieces, what’s going to happen to my nephews, what’s going to happen to cousins, my aunts, my friends that’s living in the hood?” Cardi asked in an Instagram Live video on Sunday.

This message shouldn’t be easily dismissed. The cuts come at a time when poor and working-class residents of the city are already struggling with the spiraling costs of housing and essentials, including food. New York was the epicenter of the pandemic in the United States. More than 45,000 people died after the federal, state and municipal governments failed the city’s residents.

Recovery has been slow. The unemployment rate in New York remains nearly double the national average. At the same time, the bureaucratic hiring process throughout much of the city’s municipal government has resulted in thousands of unfilled jobs in human services agencies, leading to extended wait times to receive vital federal benefits for food stamps and other assistance. This is unacceptable, and something Mr. Adams needs to fix. More than 89,000 people are living in city shelters. One in three renters are spending at least half of their income on rent.

New York City’s chronic overspending clearly helped produce this problem. But the state also has a responsibility to the city. So does the federal government.

Adams administration officials say New York has spent $2.7 billion over the last 20 months to house migrants crossing the Southern border, and the city expects to spend up to $11 billion through fiscal year 2025, which begins in July. Mr. Adams has vehemently demanded the White House reimburse the city for these ongoing expenses, and asked for much more help from the state. He’s right. Though the migrants didn’t create the city’s budget crisis, the cuts to city services would be far less steep if New York was properly reimbursed for them.

Helping New York City would be good business for Washington. In 2022 alone, New York City’s economy made up 4.7 percent of the country’s economic output, according to the Citizens Budget Commission. In the five years before the pandemic, taxpayers in New York State sent $142.6 billion more to the federal government than they received. Now is the time for the federal government to return the favor.

The New York governor, Kathy Hochul, this week signaled a willingness to help with paying for migrant services and public safety. But she also said she would oppose any effort to raise taxes in Albany, cutting off a much larger potential revenue source for the city.

“I don’t have the answers today on what we’ll do, other than I know we’ll be there to help the city once again,” Ms. Hochul said at a news conference. Since it is New York City that drives the state’s economy, fills its coffers and funds the bulk of its regional transit system, it should be in Ms. Hochul’s interest to do everything she can to find the city some relief.

For the Biden administration, there are national politics to consider. Strikingly, Cardi B questioned how the country can afford to fight foreign wars yet expects the poorest Americans to absorb cuts to basic services like libraries, education, sanitation and the police. In raising this point, Cardi B became part of a long tradition of Black American artists and others who, with sharp tongues, have questioned the nation’s priorities. If deeper cuts do come to New York, or elsewhere, American voters most affected may begin to ask themselves the same question.