The Standard & Poor's 500 index had its sixth straight gain, the longest winning streak since July.
Stocks set new highs in early August, but worries over Syria have pushed them lower since then. Even though Syria isn't a big oil producer, the possibility of a wider conflict in the region drove oil prices to two-year highs last week.
On Tuesday, investors were relieved that Syria accepted a proposal to put its chemical weapons under international control for dismantling. The possibility that the crisis between the U.S. and Syria might be solved peacefully was a factor in the stock market's gain on Monday, too.
The Dow Jones industrial average rose 127.94 points, or 0.9 percent, to close 15,191.06. The Standard & Poor's 500 index rose 12.28 points, or 0.73 percent, to 1,683.99 and the Nasdaq composite rose 22.84 points, or 0.62 percent, to 3,729.02.
Crude oil, which closed above $110 a barrel on Friday, lost $2.13, almost 2 percent, to close at $107.39 a barrel.
All 10 industry groups in the S&P 500 rose. The biggest gains were in financial and industrial stocks.
Despite the recent gains for stocks, Ralph Fogel of Fogel Neale Partners thinks it's about time for a pullback in the market. He noted that it's close to the five-year anniversary of the financial crisis, and the Dow has more than doubled since then.
The years since the crisis brought "almost a straight-up market without a 15 percent correction. That's a pretty neat move," he said. "That doesn't mean you have to have one, but the probability starts to get higher and higher."
"The next significant move isn't up 20" percent, he said. "It's down 20."
Scott Wren, a senior equity strategist for Wells Fargo Advisors in St. Louis, said investors are still nervous.
"A lot of our clients are sitting on too much cash and are kind of paranoid of the market," he said. He expects stock prices to be volatile over the next few months because of the debate over the U.S. debt ceiling as well as elections in Germany.
The Dow average got a shakeup on Tuesday. It's dropping Bank of America, Hewlett-Packard and Alcoa, to be replaced by Goldman Sachs, Nike, and Visa at the start of trading on Sept. 23. The Dow is made up of 30 stocks.
S&P Dow Jones Indices said the change won't disrupt the level of the industrial average. It said it made the change to diversify the sector and industry group representation of the index.
Hewlett-Packard fell 9 cents, or 0.4 percent, to $22.27. Alcoa was roughly flat and Bank of America rose 13 cents, or almost 1 percent, to $14.61.
Visa rose $6.04, or 3.4 percent, to $184.50; Nike rose $1.42, or 2.2 percent, to $66.82, and Goldman Sachs rose $5.65, or 3.5 percent, to $165.14.
In other notable moves:
— Apple dropped $11.53, or 2.3 percent, to $494.60 after investors were underwhelmed by its new iPhone lineup.
— Microsoft rose 73 cents, or 2.3 percent, to $32.39 on rumors about who might be its next CEO when Steve Ballmer retires next year.
— Urban Outfitters fell $4.36, or 10 percent, to $38.35 after saying its third-quarter sales increases are weaker than earlier in the year.
Traders sold safe-play assets as the threat of a strike on Syria faded. Gold fell $22.70, or 1.9 percent, to $1,364 an ounce, and the yield on the benchmark 10-year Treasury note rose to 2.97 percent from 2.91 percent.
The dollar strengthened to 100.33 Japanese yen, and fell slightly against the euro.