Wall Street ended higher on Wednesday after an OPEC agreement to limit crude output fuelled a rally in oil and more than offset nervousness about a tight race for the U.S. presidency.
The energy index .SPNY had its best day since January, climbing 4.34 percent after OPEC sources said the group reached a deal to cut its oil production for the first time since 2008. Oil prices rallied as much as 6 percent.
Chevron (CVX.N) climbed 3.20 percent and Exxon Mobil (XOM.N) gained 4.40 percent. Shares of Caterpillar Inc (CAT.N), which sells heavy equipment to energy companies, jumped 4.48 percent.
A slump in oil prices has caused steep earnings declines and losses for U.S. energy producers for several quarters. S&P 500 energy companies on average are expected to post a 66 percent drop in third-quarter earnings, according to Thomson Reuters data.
"The energy sector has been the biggest drag on earnings for the past year and a half or two years, and if you can get some stability there, all of a sudden earnings start to look a lot better," said Mark Kepner, managing director at Themis Trading in Chatham, New Jersey.
Investors for months had shrugged off the Nov. 8 U.S. presidential election, but uncertainty about the election's outcome has taken centre stage since Monday's first debate between candidates Donald Trump and Hillary Clinton.
"There is this uncertainty that you don't know which way the election is going to go," said Chris Zaccarelli, chief investment officer at Cornerstone Financial Partners.
U.S. stocks reversed earlier losses and moved higher following news of the OPEC agreement.
The Dow Jones industrial average .DJI rose 0.61 percent to end at 18,339.24 points and the S&P 500 .SPX gained 0.53 percent to 2,171.37.
The Nasdaq Composite .IXIC added 0.24 percent to 5,318.55.
Seven of the 11 major S&P sectors were higher. Telecom services .SPLRCL fell 1.04 percent, the steepest of the decliners.
Some investors said that the oil deal would have only a limited ability boost crude prices, which earlier this year hit decade lows.
"There is still plenty of oil and fossil fuels in general that could come back on. The very fact you do have the U.S. as the marginal producer, it caps the oil price," said Jeff Weniger, senior portfolio strategist at BMO Private Bank in Chicago.
Nike (NKE.N) dropped 3.78 percent after the shoemaker's orders missed analysts' estimates for the third time in a row.
Paychex (PAYX.O) dropped 4.60 percent after the payroll processor lowered its full-year profit forecast.
Advancing issues outnumbered declining ones on the NYSE by a 3.13-to-1 ratio; on Nasdaq, a 1.49-to-1 ratio favoured advancers.
The S&P 500 posted 17 new 52-week highs and 3 new lows; the Nasdaq Composite recorded 101 new highs and 36 new lows.
About 7.1 billion shares changed hands on U.S. exchanges, just above the 7.0 billion daily average for the past 20 trading days, according to Thomson Reuters data.
(Additional reporting by Chuck Mikolajczakin New York and Yashaswini Swamynathan in Bengaluru; Editing by Meredith Mazzilli)