Chicago and Detroit are the U.S. cities least prepared to weather the storm of another recession because of “extraordinarily high” fixed costs and crushing pension obligations, a Wall Street rating agency concluded Tuesday.

Moody’s Investors is alone in rating Chicago bonds as junk — a Ba1 rating with a stable outlook on the city’s general obligation debt that was reaffirmed last week after the City Council approved Mayor Lori Lightfoot’s $11.6 billion budget.

Now, Moody’s is out with a new report evaluating the nation’s 25 largest cities for their ability to “handle a recession of similar magnitude” to the economic downturn a decade ago “without a material adverse credit impact.”

Four factors were weighed: fiscal volatility; reserve coverage; financial flexibility; and pension risk. Chicago and Detroit ranked dead last.

“Chicago’s extraordinarily high fixed costs, coupled with its escalating pension liabilities, make it one of the city’s least prepared for a near-term recession,” Moody’s wrote.

“The size and diversity of Chicago’s tax base and its substantial legal flexibility to tap into that base for revenues are material strengths. However, its leverage due to debt and unfunded pension liabilities — both direct city obligations and those of overlapping units of government — continue to weigh heavily on its credit profile.”

Moody’s pegged “overall median fixed costs” for the 25 cities at what it called a “moderately-high 23 percent of revenue.”

Chicago had the highest fixed costs — roughly 45 percent of revenue. It is one of seven cities with fixed costs above 30 percent of revenue.

All seven — Charlotte, El Paso, Dallas, San Jose, Houston, Fort Worth and Chicago — face an “above average challenge to maintain balanced operations if revenue decline” during a recession.

“High fixed costs for mandatory debt and retirement obligations can crowd out other spending or create a need for larger cuts to programmatic spending during a period of economic weakness, possibly prolonging a recession,” the report states.

Twelve of the 25 cities scored in the “weaker” category in, what Moody’s calls its “common pension stress test,” which combines revenue declines and asset losses” during a recession.

So-called “median adjusted net pension liabilities” in those cities “as a percent of revenue” would rise from 286 percent currently to 336 percent during a recession, the report states.

“Chicago is a negative outlier in both the pre-stress and stress scenarios” with adjusted net pension liabilities “at 575 percent and 626 percent of revenue respectively,” Moody’s said.

The mayor’s office had no immediate comment on the Moody’s report.

Lightfoot’s own three-year financial analysis forecasts a “worst case” shortfall of $1.74 billion in 2022 if the economy takes a nose-dive and a $799 million shortfall, even in the best-case scenario of a rosy economy.

The mayor’s budget forecast pegged “asset lease fund balances” created with proceeds from the Skyway and parking meter deals at $652.5 million at the close of 2018.

Civic Federation President Laurence Msall said Chicago has “a variety of strengths and opportunities that could help it weather the next financial storm.”

But Msall said those “favorable factors are dramatically outweighed” by pensions “in the worst shape of any of the 25 largest cities in the nation” — and by Chicago’s “high debt burden and other fixed costs.”

“Without a long-term financial plan available for public review, it is difficult to see how Chicago would be able to withstand a recession without significant impacts to services and financial stability,” Msall wrote in an email to the Sun-Times.

“This report is yet further evidence of the urgency in Chicago developing a long term plan for dealing with its growing pension crisis.”

Former Mayor Rahm Emanuel spent the first of his two terms trying to negotiate pension reforms that were ultimately overturned. The Illinois Supreme Court upheld a pension protection clause that says those benefits “shall not be impaired or diminished.”

That triggered a downward spiral that saw Moody’s lower Chicago’s bond rating to junk status and do the same at the Chicago Public Schools and Chicago Park District. Standard & Poor’s and Fitch announced lesser drops.

Emanuel was so incensed by Moody’s junk bond rating and the added borrowing costs associated with it, he demanded that Moody’s stop rating Chicago bonds.

Lightfoot’s first budget was precariously balanced with one-time revenues that include: A $300 million tax increment financing surplus that’s the largest in Chicago history; a $1.5 billion refinancing, with all $210 million in savings claimed up-front; and a $93 million clawback from the Chicago Public Schools for pension and security costs the city used to pay for.

The mayor is also counting on $163 million from raising ambulance fees paid by private insurers and getting federal approval for reimbursements administered by the state for ambulance transports for low-income patients on Medicaid.

That hasn’t happened yet. Lightfoot remains “very confident” the feds will green-light the ambulance plan, despite her repeated attacks on President Donald Trump.

Even after enduring an avalanche of tax increases, Chicago taxpayers are saddled with a $28 billion pension debt. Chicago taxpayers are on the hook to keep all four city employee pension funds on the road to 90 percent funding. By 2023, the city’s contribution to all four funds will nearly double—to $2.1 billion.

Lightfoot steered clear of a massive property tax increase, even after coming up empty in Springfield in her requests for a casino gambling fix and a graduated real estate transfer tax. But, all bets are off if she strikes out again during the spring session.