Stocks shifted gears and headed higher on Wednesday as energy shares jumped after a government oil inventory report showed a huge drop in crude oil supply last week, boosting oil futures almost 4 percent.

The move into positive territory for the three major U.S. indexes was a marked turnaround from earlier in the session, when stocks fell around 1 percent after a sharp drop in Chinese equities sparked fears that stock prices were not justified by economic fundamentals.

The Dow Jones industrial average <.DJI> gained 53.81 points, or 0.58 percent, to 9,271.75. The Standard & Poor's 500 Index <.SPX> gained 5.30 points, or 0.54 percent, to 994.97. The Nasdaq Composite Index <.IXIC> gained 7.89 points, or 0.40 percent, to 1,963.81.

(Reporting by Edward Krudy; Editing by Jan Paschal)