Wall Street ended higher on Tuesday as the impact of weekend attacks on Saudi Arabia's biggest oil refinery faded and investors awaited a widely expected Fed interest rate cut on Wednesday.
Stocks closed firmly in positive territory after being mixed for much of the session.
That helped make up for a hit to Wall Street on Monday after attacks wiped out nearly half of Saudi Arabia's oil production, sending oil prices soaring and fuelling geopolitical tensions.
The S&P 500 is less than 1pc short of its record high close on July 26.
Investors were calmed after US President Donald Trump said he did not want war and Saudi Arabia said it would restore its lost output by the end of September.
“People were thinking it would be months until we got that production back on line, and now it seems more like weeks.
Putting that production back on line alleviates the risk of a higher disruption," said Keith Buchanan, a portfolio manager at GLOBALT Investments in Atlanta.
The S&P energy index dipped 1.5pc after recording its strongest one-day surge since January on Monday.
The so-called defensive consumer staples, utilities and real estate posted some of the biggest gains among the 11 major S&P sectors.
Overall, nine sectors rose on Tuesday, with only energy and industrials ending lower.
The US Federal Reserve concludes its two-day policy meeting on Wednesday, where the central bank is expected to lower interest rates by a quarter percentage point, the second rate reduction of the year.
Investors will also wait for clues on how far the US monetary policy easing would go, given that Fed policymakers are deeply divided on whether more rate cuts are warranted.
“Its going to be difficult for them to signal an extremely dovish tone, given they are already half divided at this point," said Chris Zaccarelli, chief investment officer at Independent Advisor Alliance, in Charlotte, North Carolina.
The S&P 500 bank index, which tends to underperform in a lower interest rate environment, fell 0.6pc.
Economic reports were upbeat, as US manufacturing output increased more than expected in August, while homebuilders' optimism crept up in September.
The Dow Jones Industrial Average edged up 0.12pc to end at 27,109.03 points, while the S&P 500 gained 0.26pc to 3,005.61.
The Nasdaq Composite added 0.4pc to 8,186.02.
Among stocks, Chipotle Mexican Grill Inc jumped 3.2pc as it added a new steak dish to its menu in the United States for the first time in three years.
Home Depot Inc dropped 0.3pc after Guggenheim downgraded the home improvement chain's shares to “neutral" from “buy."
Corning Inc slumped 6.1pc after the Gorilla glass maker cut its current-quarter display volume forecast.
Kraft Heinz Co tumbled 4.3pc after the packaged food maker's second-largest investor, 3G Capital, sold over 25 million shares in open market at a discount.
Advancing issues outnumbered declining ones on the NYSE by a 1.17-to-1 ratio; on Nasdaq, a 1.18-to-1 ratio favored decliners.
The S&P 500 posted 17 new 52-week highs and 1 new low; the Nasdaq Composite recorded 57 new highs and 29 new lows.
Volume on US exchanges was 6.8 billion shares, about average over the last 20 trading days.