The Dow and the Nasdaq eked out gains on Wednesday as a late-stage rally brought stocks off their lows on hopes that the quarterly earnings season would deliver good news.

Despite the rebound from steeper losses earlier in the day, a negative tone still characterized trade as investors worried whether an economic recovery would take hold.

After the market close, however, aluminum giant Alcoa Inc reported a smaller-than-expected loss that gave a positive tone to the start of the second-quarter earnings season. Its shares jumped 7 percent to $10.07 in extended trading.

My own sense of it is that manufacturing companies should do a lot better in the third-quarter simply because the inventory liquidation we saw in the first half of the year was huge, it was absolutely huge, said Charles Lieberman, chief investment officer of Advisors Capital Management, LLC in Paramus, New Jersey, after Alcoa reported.

Stocks were sharply lower for most of the day as investors worried that an economic recovery will be slower than thought. Those fears helped send crude oil futures to a more than a six-week low, while copper, a barometer for global demand, hit a two-week low as commodities sold off across the board.

The tone of the trading day definitely was to the downside, said Weston Boone, vice president of listed trading at Stifel Nicolaus Capital Markets in Baltimore.

He pointed to a deterioration in sentiment over the last few day after U.S. June payrolls data came in worse than expected at the end of last week.

Kevin Kruszenski, head of listed trading at KeyBanc Capital Markets in Cleveland, noted that a late rally may have been triggered by people jockeying for position ahead of Alcoa's earnings.

The Dow Jones industrial average <.DJI> gained 14.81 points, or 0.18 percent, to 8,178.41. The Standard & Poor's 500 Index <.SPX> dropped 1.47 points, or 0.17 percent, to 879.56. The Nasdaq Composite Index <.IXIC> added 1.00 points, or 0.06 percent, to 1,747.17.

The S&P Energy index <.GSPE> fell 0.1 percent as ConocoPhillips dropped 1.4 percent to $39.44. Crude oil settled down 4.4 percent to $60.14 per barrel. US Steel Corp dropped 3.6 percent to $30.50 with declining metal prices.

The U.S. Energy Information Administration released data that showed gasoline and distillate inventories rose more than expected last week, pointing to ongoing weakness in demand -- adding to fears about the economy.

Shares in the healthcare and consumer staples sectors, traditionally seen as better able to weather a weak economy, helped boost indexes as stocks such as Johnson & Johnson and Merck & Co , both up around 1.5 percent, helped push the Dow industrials into positive territory late in the session.

After a rally that pushed up the S&P 500 as much as 40 percent from 12-year lows in early March, investors have been met with a rash of data -- especially the weaker-than-expected June U.S. payrolls report last week -- that has undermined hopes for an economic rebound.

Trading was moderate on the New York Stock Exchange, with about 1.44 billion shares changing hands below last year's estimated daily average of 1.49 billion, while on Nasdaq, about 2.52 billion shares traded, above last year's daily average of 2.28 billion.

Declining stocks outnumbered advancing ones on the NYSE and the Nasdaq by around two to one.

(Editing by Leslie Adler)