Stocks advanced on Wednesday as a strong rebound in oil prices boosted investors' confidence in the market's run-up, sending major indexes up close to 1 percent.

The surge in crude oil erased early losses triggered by a heavy sell-off overnight in Chinese shares.

Exxon Mobil Corp and Chevron Corp , both Dow components, rose more than 2 percent, contributing the most to the index's advance. Exxon Mobil was up 2.4 percent at $68.09, and Chevron gained 2.2 percent to $68.39. The S&P Energy Index <.GSPE> gained 2.2 percent.

U.S. front-month crude oil rose 3.2 percent to $72.45 a barrel after a report showed the biggest drop in inventories since May.

Wall Street had opened lower after the Shanghai Composite index <.SSEC> fell to a two-month low as investors fretted that a 20 percent slide over the past two weeks would continue.

We see more people shrugging off overseas weakness and putting money into equities here, not wanting to see the stocks come down, said Michael James, senior trader Wedbush Morgan in Los Angeles.

Firmer oil prices are helping the overall equities market, but there is a positive bias toward equities to begin with.

The Dow Jones industrial average <.DJI> was up 73.54 points, or 0.80 percent, at 9,291.48. The Standard & Poor's 500 Index <.SPX> was up 7.71 points, or 0.78 percent, at 997.38. The Nasdaq Composite Index <.IXIC> was up 13.24 points, or 0.68 percent, at 1,969.16.

Healthcare stocks were also outperforming, lead by Merck & Co. . The drugmaker was up 3.5 percent to $31.79, and Pfizer Inc also added 2.1 percent to $16.31.

The tech-heavy Nasdaq index was slightly underperforming others. Hewlett-Packard Co was down 0.5 percent at $43.73 after expressing caution about business demand late on Tuesday. Earlier, H-P hit an intraday low at $42.52.

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

(Editing by Padraic Cassidy)