Chevron jumped 4 percent, the most in the Dow Jones industrial average. Exxon Mobil also gained 3 percent.
Energy stocks climbed as the price of oil turned higher, shaking off a two-day slump. U.S. crude gained 2 percent.
Banks and other financial stocks were the only sector to fall.
The Dow gained 200 points, or 1.2 percent, to 16,472. It was down as much as 258 earlier.
The Standard & Poor's 500 index rose 27 points, or 1.4 percent, to 1,951. The Nasdaq composite rose 80 points, or 1.7 percent, to 4,707.
Bond prices rose. The yield on the 10-year Treasury note fell to 1.98 percent.