By Harriet Torry and Sarah Nassauer

U.S. shoppers opened their pocketbooks at malls and auto dealerships in May as states eased lockdowns to contain the coronavirus pandemic, driving a record month-over-month increase in retail spending.

Retail sales, a measure of purchases at stores, at restaurants and online, increased a seasonally adjusted 17.7% in May from a month earlier, the Commerce Department said Tuesday. Still, retail spending remained below prepandemic levels in May, totaling $485.5 billion compared with $527.3 billion in February.

The May increase was the biggest in records dating back to 1992, and smashed economists' expectations for a 7.7% increase.

"The U.S. consumer's back big time and she's spending," said Craig Johnson, president of Customer Growth Partners, a retail consulting firm.

Stock markets jumped on the retail-sales news.

From a year earlier, retail sales were down 6.1% in May. May's month-over-month jump followed the largest monthly drop on record in April, a revised 14.7% decline. The swing in retail sales reflected the nature of the shock from the pandemic, where the coronavirus and related lockdown shut off an economy that previously was growing at a steady pace -- and reopenings restored at least some demand for goods.

"The big question going forward is to what extent does employment snap back to precrisis levels," a prerequisite for continued spending, said Joshua Shapiro, chief U.S. economist at MFR Inc. May's unemployment rate dropped to 13.3% from 14.7%, and employers added 2.5 million jobs to payrolls, an improvement but well below levels before the pandemic.

Other data released Tuesday pointed to a pickup in other areas of the economy. The Federal Reserve said U.S. industrial production -- a measure of factory, utility and mining output, which includes oil and natural gas production -- increased a seasonally adjusted 1.4% in May. Home builders' confidence also returned to positive territory in June, the National Association of Homebuilders said.

Still, the U.S. economy still has a long way to go to recover -- economists project it could take years -- and recent increases in coronavirus cases in more than a dozen states are casting a cloud over reopening efforts.

May's retail sales increase followed three straight months of declining retail sales, and offered a fresh sign that the worst of the economic shock from the pandemic likely occurred in late March and April when widespread shutdowns to contain the virus were in place across the country.

Consumer spending is the main driver of the U.S. economy, accounting for more than two-thirds of economic output, and retail sales account for about a quarter of all consumer spending. Social distancing, lockdowns and travel restrictions took an unprecedented toll on household spending in March and April.

Americans increased their outlays across the board in May, though the increase was driven by a 44.1% month-over-month rise in spending on motor vehicles, which make up about a fifth of retail sales.

Furniture and apparel sales, which fell precipitously during coronavirus lockdowns, posted strong gains, with sales at clothing stores rising 188% from the prior month and furniture sales jumping 89.7%.

Still, "the performance of individual sectors varies enormously," said Neil Saunders, managing director of GlobalData Retail. Department and clothing store monthly sales fell versus last year as many remained closed or partially closed during the month. In addition, "extensive discounting, designed to clear down inventory, has also dampened sales values," said Mr. Saunders.

Receipts at bars and restaurants jumped nearly 30% in May from April, but were down nearly 40% year-over-year.

Tuesday's report tracked spending on mostly goods, and not services such as health care and travel. The figures weren't adjusted for inflation.

As states allow businesses to reopen there are signs consumers are ready to spend, at least a little. Shoppers flocked to a T.J. Maxx store in Ann Arbor, Mich. on Monday, many eager to see and touch clothes, jewelry and shoes in real life.

Sheri Hudson, a retired 55-year-old who lives in Monroe, Mich., said she has been shopping more as stores reopened in recent weeks, including driving half an hour south to Ohio because stores opened there in May. "The whole time we were on house arrest, I went down there to do my shopping," said Ms. Hudson, placing discounted designer clothes in her cart.

Some shoppers say they are being cautious with their spending, even though they are still employed. "I've cut back a lot because the economy is the way it is," said Sue Vaandering, a 51-year-old from Brighton, Mich. She is buying essentials for her family such as food and household goods, and starting to buy more summer supplies, but is cutting back on clothes, she said.

Grocery store sales have remained strong throughout the pandemic, and sales at home improvement, sporting goods and online retailers were up both on the month and the year.

In recent weeks, retail executives said that spending picked up at the end of April and into May, and that shoppers returned to reopened stores faster than expected. Private data also suggest that economic activity continued to rise in early June.

Costco Wholesale Corp. comparable sales, those from stores or digital channels operating at least 12 months, rose 9.7% in May. Sales of discretionary and nonfood items such as bedding, appliances and sporting goods "rebounded in May compared to recent months," while food sales stayed strong, a Costco executive said on a prerecorded call to discuss monthly sales. Walmart Inc. and Target Corp. executives also said last month that spending picked up at the end of their most recent quarters in late April.

Write to Harriet Torry at harriet.torry@wsj.com and Sarah Nassauer at sarah.nassauer@wsj.com