The battered financial sector also rallied back from earlier weakness, with investors encouraged by an extension of rules banning illegal sales of key financial stocks.
The market had opened sharply higher before slumping as the price of oil bounced back following data that showed national inventories of gasoline fell last week.
But "[the crude oil market] closed and the market is getting the sense that the economic data is getting a little better and that financials may have hit a bottom," said Art Hogan, chief market strategist at Jefferies.
The Dow Jones Industrial Average gained 186 points to end at 11,583, near its high of the session and well off an earlier low of 11,397.
The blue-chip average has now rallied more than 451 points over the past two sessions.
Of the Dow's 30 components, 26 advanced, with shares of oil giants Chevron Corp. and Exxon Mobil Corp. , along with those of aluminum producer Alcoa Inc. , pacing gains among blue chips.
Also among blue-chips, shares of Walt Disney Co. gained 2.4% ahead of the entertainment firm posting quarterly profit of $1.28 billion, or 66 cents a share, after the close. Analysts polled by FactSet Research expected, on average, earnings of 61 cents a share.
The S&P 500 index rose 21 points, or 1.7%, to end at 1,284, with the broad index's gains led by a 6% surge in the energy sector and a 2% gain in the materials sector.
A day after surprisingly strong results from U.S. Steel Corp. , leading global steelmaker ArcelorMittal said second-quarter profit more than doubled and issued an upbeat outlook for the third quarter.
The broad market continued to find support from the financial sector. The Securities and Exchange Commission extended rules to protect shares of key financial firms, including housing-finance giants Fannie Mae and Freddie Mac , believed to have been the subject of illegal short sales.
Ailing financials had already rebounded Tuesday after Merrill Lynch announced it would offer $8.5 billion in stocks to cover investment losses. Financials and the broader market fell sharply on Monday after news of more bank failures over the weekend.
"The Merrill news has boosted hope that we've had the capitulation, the event allowing us to rebound from here," said Owen Fitzpatrick, head of U.S. equities at Deutsche Bank.
Meanwhile, the Nasdaq Composite rebounded after slipping into negative territory to finish up 10 points, or 0.4%, at 2,329.72.
Selling pressure earlier hit the technology-heavy index as shares of Electronic Arts fell 6.6% after the video-game publisher posted a quarterly loss.
Trading volumes showed 1.5 billion shares exchanging hands on the New York Stock Exchange and 922 million trading on the Nasdaq stock exchange. Advancing issues outpaced decliners by a ratio of 2 to 1 on the NYSE and of 4 to 3 on the Nasdaq.
Slight rise in jobs
The ADP estimate of July employment indicated a 9,000 improvement in private-sector jobs. Economists surveyed by MarketWatch had been looking for a 50,000 decline, in line with the jobs weakness gripping the U.S. economy throughout 2008.
The employment figure, which excludes government jobs, comes two days before the official Labor Department report, which economists expect will show a reduction of 70,000 jobs for the month.
But the ADP report's reliability as an indicator is in dispute. The report's "losing credibility by the month as a predictor of nonfarm payrolls," said Robert Kavcic, an economist at BMO Capital Markets.
The data still helped boost the dollar, which in turn put some pressure on commodities. A firmer U.S. urrency makes dollar-denominated commodities, such as crude oil and gold, more expensive for holders of other currencies.
Oil still rallied sharply after the Energy Department reported a drop in gasoline inventories, while conflicts in Nigeria and tensions surrounding Iran also fueled gains. A barrel of crude oil gained $4.58, or nearly 4%, to end at $126.77.
Elsewhere, shares of Garmin Ltd. fell sharply after the navigation device maker cut its 2008 outlook.
Corning also fell, retreating after giving a cautious outlook on third-quarter sales.
Elan tumbled and Wyeth dropped sharply, as the drugmakers said a Phase II study of an Alzheimer's disease drug didn't generate statistically significant results.
By Nick Godt