Consumer and technology stocks, including Amazon, led gains on Wall Street on Tuesday, while a perceived win by Democrat Hillary Clinton in Monday's first presidential debate gave broader support to equities.
The S&P 500 technology sector rallied 1.15 percent, powered by a 1.85 percent gain in Microsoft and a 1.08 percent rise in Facebook.
Amazon.com jumped 2.12 percent and the consumer discretionary index gained 0.99 percent after a report showed that the consumer confidence index for September rose to its highest level in nine years.
Following the first of three presidential debates on Monday, Republican candidate Donald Trump vowed to hit Clinton harder after she put him on the defensive. With six weeks until the November 8 vote, some investors see the neck-and-neck contest sparking volatility in sectors including health insurers, drugmakers and industrials.
"From a market perspective, rightly or wrongly, there is an understanding that Mrs. Clinton would be a safe pair of hands, that there's very little uncertainty there," said Brad McMillan, chief investment officer for Commonwealth Financial in Waltham, Massachusetts.
Still, shares of private prison operators Corrections Corp and Geo Group fell 7.39 percent and 3.82 percent respectively after Clinton criticized states' use of for-profit prisons during the debate.
In their first increases in three sessions, the Dow Jones industrial average rose 0.74 percent to end at 18,228.3 points and the S&P 500 gained 0.64 percent to 2,159.93.
The Nasdaq Composite added 0.92 percent to 5,305.71.
The increase in the consumer confidence index also boosted shares of Coca-Cola Co, up 1.28 percent, and Nike, which rose 1.73 percent.
"Consumer stocks seem to be catching a bit after having a hard time for probably a month or two," said Mark Spellman, portfolio manager at Alpine Funds in New York.
Oil prices plunged 3 percent as hopes for a deal to cut output faded at major producers meeting in Algeria. The S&P 500 energy index fell 0.46 percent.
Gilead Sciences was the top drag on the S&P and the Nasdaq, falling 1.70 percent after Leerink downgraded the drugmaker's stock to "market perform."
Advancing issues outnumbered declining ones on the NYSE by a 1.42-to-1 ratio; on Nasdaq, a 1.92-to-1 ratio favoured advancers.
The S&P 500 posted 12 new 52-week highs and 2 new lows; the Nasdaq Composite recorded 82 new highs and 34 new lows.
About 6.2 billion shares changed hands on U.S. exchanges, below the 6.9 billion daily average for the past 20 trading days, according to Thomson Reuters data.