Stock indexes turned higher on Wednesday, erasing earlier losses on strength in crude oil prices after a surprising drawdown in oil stocks.

The markets had fallen in earlier trading, pressured by a sell-off in China, as well as weak outlooks from Deere & Co and Hewlett-Packard . The news fed existing concerns that stock prices have outpaced the economic recovery.

But markets turned, led by a jump in crude oil, after data from the Energy Information Administration showed that stockpiles unexpectedly fell 8.4 million barrels last week, the biggest drop in crude stocks since May.

The news lifted September crude futures 2.2 percent to $70.72 per barrel, while the S&P Energy Index <.GSPE> gained 2 percent to 386.12. Exxon Mobil shot up 2.1 percent to $67.87. The energy index was the S&P's top index performer while Exxon contributed the most to the Dow's advance.

Oil is helping us, said Rick Meckler, president of LibertyView Capital Management in New York. It's a big part of the index and energy companies have helped turn this market before.

In China, the Shanghai Composite index <.SSEC> dropped to a two-month low as investors bailed out on worries that a 20 percent slide over the past two weeks would continue to deepen.

Investors were having these short-term fears based on China, but the reality is that if you put the short-term out of your mind, the next 12 to 18 months look pretty good, said Rick Campagna, portfolio manager at Provident Investment Council in Pasadena, California.

China's market got a little ahead of itself, but I think investors are shrugging it off now, he added.

The Dow Jones industrial average <.DJI> rose 65.68 points, or 0.71 percent, to 9,283.62. The Standard & Poor's 500 Index <.SPX> added 6.37 points, or 0.64 percent, to 996.04. The Nasdaq Composite Index <.IXIC> gained 10.74 points, or 0.55 percent, to 1,966.66.

Weighing on the tech-heavy Nasdaq was Hewlett-Packard, which late Tuesday reported third-quarter results that beat expectations, but expressed caution about business demand.

After falling in early trading, HP shares were almost flat, inching down 0.2 percent to $43.89. Earlier, HP hit an intraday low at $42.52.

Also limiting gains was Deere, which shed 3.2 percent to $43.67 after it said it expected to barely break even in the fourth quarter.

(Editing by Jan Paschal)