By Thomas Gryta and Theo Francis

Cash remains king for large publicly traded U.S. companies adjusting to an economy and operations sharply changed by the coronavirus pandemic.

Giant companies from McDonald's Corp. to Intel Corp. are husbanding the cash they accumulated during the decadelong expansion that ended in February, as well as cutting costs and tapping debt and other sources of liquidity, all as a cushion against persistent uncertainty.

At the same time, corporate leaders and investors are gauging when it will make sense to economize less and spend more to avoid losing out to rivals once the recovery begins in earnest.

"I would just want to get through a couple more months of understanding what that recovery looks like," Robert McMahon, chief financial officer of life-sciences company Agilent Technologies Inc., told investors in early June. "Liquidity is still an asset that we want to have in our back pocket. We have a lot of it, and I think it will serve us well versus some of our competitors when we come out of this."

As the pandemic swept the U.S., large companies significantly increased cash and short-term investments as well as total debt -- much more rapidly than they did in the preceding quarters, according to a Wall Street Journal analysis of financial data from S&P Global Market Intelligence.

For S&P 500 companies, the median increase in cash and short-term investments was 13.9% in the March quarter, compared with less than 4.1% in the prior three quarters, the analysis found. The degree to which firms spent or saved those funds will be evident when they report second-quarter results starting next month.

PepsiCo Inc. borrowed $7.6 billion in the first quarter, doubling the cash on its balance sheet. Hilton Worldwide Holdings Inc. raised $1 billion by selling loyalty points. Home builder Lennar Corp. paused land purchases. Carnival Corp. has put six of its ships up for sale. And Agilent was among those that continued to draw on operations abroad during the spring by repatriating foreign profits.

Companies stockpile cash in a crisis for much the same reason households do: It provides flexibility in an uncertain environment, protecting against further crises or suddenly parsimonious capital markets. It also serves as ready fuel once sustainable growth resumes and new investment makes sense.

"The real clarity is going to be when they know what spikes in the virus mean for consumer behavior," said Blair Effron, co-founder of investment bank Centerview Partners LLC. Companies know the economy is bad now, he said, but need to better understand what it will look like in coming months.

Central bankers around the world have committed to providing liquidity to banks and companies. As a result, in contrast to the financial crisis of 2008 and 2009, when lending and investment capital evaporated suddenly, healthy companies aren't having difficulty getting access to cash, making it even easier to keep their tanks full.

Cheap debt has made that reflex easier to indulge even while spending to expand or maintain operations. The Federal Reserve cut interest rates in March near zero and has been buying Treasurys and mortgage-backed securities. It said it stands ready to buy corporate bonds, pushing down borrowing costs.

Even embattled businesses have been able to fill their coffers. Gap Inc. said in early May that it had raised $2.25 billion, about a month after it had closed its U.S. stores and drawn down its full $500 million credit line. Gap later closed that credit line and has yet to tap its replacement, a spokeswoman said. Hilton borrowed $1.5 billion from its credit line, which it called a precautionary measure, closing its books for the March quarter with more than triple the cash that it had on Jan. 1. It sold loyalty points and new debt to raise another $2 billion in April.

"Holding cash gives more flexibility to the company in terms of what it should do," said Lee Pinkowitz, an associate professor of finance at Georgetown University whose research has shown that investors value cash more highly in a crisis. The pandemic, civil unrest and political turmoil are stirring up the kind of fear that leads to cash hoarding, he added. "The higher the uncertainty, the more valuable that option is."

Among nonfinancial companies in the S&P 500, half increased their debt by at least 3.38% during the first quarter from the fourth quarter, according to the Journal analysis. By contrast, in the prior three quarters, the median increase in debt for the companies never exceeded about 0.2%.

Much of the proceeds were just stashed away. For example, McDonald's borrowed $4.8 billion -- increasing total debt by 10% -- and end the first quarter with cash up $4.5 billion. Chip giant Intel was similar, borrowing $10.4 billion, increasing its total debt 35% and ending the quarter with cash and related investments up $7.7 billion.

Not every company increased its liquid reserves. Apple Inc., which has accumulated one of the biggest hoards of cash and investments, spent it down by about $13 billion in the first quarter, or about 12%. In April, finance chief Luca Maestri said Apple's strong balance sheet, cash flow and access to capital markets means the company hasn't faced liquidity problems.

Smaller companies, too, have used a range of tools to conserve cash. Jeans-maker Guess Inc. slashed capital expenditures by more than 60% and operating costs by 30% compared with a year earlier based on revised models of consumer demand, and extended payment terms with some vendors, Chief Financial Officer Katie Anderson said.

Choice Hotels International Inc. laid off or furloughed about 20% of its workforce, temporarily eliminated its 401(k) match and paused share buybacks and dividends, among other cost cuts, its finance chief, Dominic Dragisich, said. Those and future cost-cutting opportunities give the company enough liquidity to continue day-to-day operations for three years if necessary, Mr. Dragisich said. The company also borrowed $250 million as a precaution, and hasn't spent the proceeds.

There are likely long-term benefits to accumulating and safeguarding cash in a crisis. In January, Bank of England researchers concluded that U.K. companies with high cash holdings beforehand were able to invest more during the financial crisis and the subsequent recovery. Ultimately, cash-rich firms captured market share and increased profits.

"Having a liquid balance sheet when the credit cycle turns thus gives firms a competitive edge that lasts far beyond the crisis years," the paper concluded.

Today's executives understand that lesson, said Mr. Effron, the investment banker, who has counted General Electric Co. and PepsiCo among his clients. Rather than focus on the fear of the moment, they are already thinking about how to improve their businesses for the years ahead. But there are limits.

"The fact is that profits are down; therefore leverage is up," he said. "Companies are going to be hobbled a little bit from doing everything."

Executives are echoing that sentiment as they talk to investors, voicing both an attentiveness to investment opportunities and a hesitation to return immediately to spending on increased dividends, acquisitions and share repurchases.

Baxter International Inc. finance chief James Saccaro said June 9 the medical-instrument maker is postponing buybacks because of market volatility and "a lot of uncertainty around how things could emerge."

Baxter borrowed $1.2 billion in the first quarter, increasing its debt by 20%, and increased its cash and short-term investments to $4.1 billion.

In many cases, big companies have spent heavily in the face of sharply lower revenues to maintain operations and workforces, and to retrofit stores or workplaces for operating during a pandemic, or to make working from home easier.

At the same time, other spending has been put on hold, such as travel, wooing potential customers and attending conferences. As businesses are reopening, these costs will return and put pressure on corporate budgets, executives and analysts said.

Lennar, for example, limited cash outflows in part by delaying land acquisitions for two to three months, and the home builder is evaluating the pace of new projects daily. "The endgame of all that was an intense focus on managing cash and preserving the strength of our balance sheet, " finance chief Diane Bessette said.

--Kristin Broughton and Mark Maurer contributed to this article.

Write to Thomas Gryta at thomas.gryta@wsj.com and Theo Francis at theo.francis@wsj.com