Stocks rallied on Wednesday as investors rushed back into beaten-down stocks, led by energy, which bore the brunt of the sell-off a day earlier.

The energy sector handily led the way up with the S&P energy index <.GSPE> gaining 4.3 percent. Shares of Halliburton rose 12 percent after executives said the offshore oil industry had plenty of work even as the Obama administration imposed a six-month moratorium on deep-water drilling.

While investors still are cautious about the outlook for energy stocks, the genuine blood bath in the sector yesterday certainly seems to have drawn in some fundamental value seekers, said Craig Peckham, equity trading strategist at Jefferies & Company in New York.

U.S.-listed shares of BP Plc climbed 3.1 percent to $37.66 even as the company hit a snag in its latest effort to halt the oil spill in the Gulf of Mexico. The stock is down close to 38 percent since the rig explosion on April 20.

Major automakers posted double-digit U.S. sales gains in May from depressed levels a year earlier, including Ford Motor Co , which rose 3.9 percent to $11.85.

The Dow Jones industrial average <.DJI> gained 225.52 points, or 2.25 percent, to 10,249.54. The Standard & Poor's 500 Index <.SPX> rose 27.67 points, or 2.58 percent, to 1,098.38. The Nasdaq Composite Index <.IXIC> climbed 58.74 points, or 2.64 percent, to 2,281.07.

Investors also were encouraged by data showing pending sales of previously owned homes increased to a six-month high in April, though analysts pointed to a rush to take advantage of the home buyer's tax credit before it expired.

The PHLX Oil Service Sector index <.OSX> climbed 5.5 percent with Halliburton Co rising to $23.68 and Schlumberger Ltd gaining 8.8 percent to $56.31.

This is a bit of a relief recovery after yesterday and the strongest symptom of that is the action we're observing in the energy sector, said Lawrence Creatura, portfolio manager at Federated Clover Investment Advisors in Rochester, New York.

Investors are observing the large amount of market capitalization which has been destroyed across the industry and calculating that that damage is too large relative to the ultimate liability that we're going to see, said Creatura.

United Airlines parent UAL Corp jumped 12.6 percent to $21.78 after Bank of America-Merrill Lynch reinstated the company with a buy rating, saying it had good momentum whether or not it merged with Continental Airlines .

Amgen Inc helped boost the Nasdaq, gaining 10.5 percent to $56.09 after the U.S. Food and Drug Administration approved the sale of its osteoporosis drug to help prevent fractures in post-menopausal women.

(Reporting by Leah Schnurr; Editing by Kenneth Barry)