It was a relief for investors after the big drops of the previous week.
Stocks fell in morning trading, with the Dow Jones industrial average down almost 63 points. But they turned around after the government said businesses are restocking their shelves faster than analysts had expected.
The Commerce Department said U.S. wholesale stockpiles grew 0.6 percent in April. That's twice as fast as they grew in March and a sign that businesses are ordering enough goods to lead to increased factory production and sales. Investors had been braced for more sluggish growth.
Oil fell 72 cents to $84.10 per barrel. Sure, it was pushed down by long-term economic worries. But lower energy costs help consumers.
"If you had some doubts about an economic recovery, oil in the $80s is a lot better than oil at $110," said Jim Dunigan, managing executive of investments for PNC Wealth Management in Philadelphia. Oil traded just below $110 in late February.
The Dow finished 93.24 points higher, or three-quarters of a percent, at 12,554.20. It ended the week up almost 3.6 percent.
The Standard & Poor's 500 index rose 10.67 points, or 0.81 percent, to close at 1,325.66. The Nasdaq composite rose 27.40 points, or 0.97 percent, to close at 2,858.42.
Nine out of the ten industry groups in the S&P 500 rose. Only energy stocks declined, following energy prices lower.
Wal-Mart Stores was the biggest gainer in the Dow, up $2.35, or 3.6 percent, at $68.22. Other companies that depend heavily on a strong economy grew too, including Intel, up 47 cents, or 1.8 percent, at $26.41, and General Electric, up 20 cents, or 1 percent, to $19.20. Home Depot rose $1.11, or 2.2 percent, to $52.35.
Facebook rose 79 cents, or 3 percent, to $27.10 after announcing an "app center" that will recommend new add-on software for users. Anything that boosts user interaction is likely to help it sell more ads, which has been a key concern for investors in its new stock, which debuted three weeks ago at $38.
Chesapeake Energy shareholders punished their directors and were rewarded by the market. The stock rose 51 cents, or 2.9 percent, to $18.36 after shareholder votes prompted the resignations of two directors at the company's annual meeting Friday. Earlier in the day the company said it will sell pipeline assets in three deals for a total of more than $4 billion in cash.
Navistar International rose $4.25, or 17.6 percent, to $28.36 after the activist investor Carl Icahn boosted his stake in the truck maker.
Markets fell in Asia. Shanghai's stock index lost a half-percent, its fifth day of losses. Japan's Nikkei fell 2.1 percent.
Chinese leaders have been showing signs of urgency ahead of May trade and industrial data due out this weekend that might be even weaker than earlier pessimistic forecasts. The Chinese government cut interest rates for the first time in four years and has reduced gasoline and diesel prices for the second time in a month.
Over the long run, that will put more money in the pockets of Chinese consumers. In the short run it's a sign that the government is worried about growth.
"That shows they're being proactive, but on the other hand, it also makes you wonder, what's the data is really like?" said Uri Landesman, president of Platinum Partners. "I'm wondering how bad the data's going to be. I'd be very surprised if it's good."
China is a key U.S. trade partner so its growth is important to U.S. companies. Its importance is magnified by the possibility that Europe's economy will go from slow growth to shrinkage, Landesman said.
Major European markets fell, although their declines were smaller after the U.S. inventory news came out. France's benchmark index lost 0.6 percent, Britain's and Germany's each dropped 0.2 percent.