Gold futures hit their highest since early November. The rally in the safe-haven asset surprised some analysts.
"I think there's still — bigger picture outside today — concerns about growth and where we're headed. ... Still people are concerned they don't know where energy prices are heading, they don't know what the Fed is going to be saying," said Robert Pavlik, chief market strategist at Boston Private Wealth.
The Dow closed about 280 points higher after earlier adding 300 points. 3M contributed the most to gains, followed by Goldman Sachs, which closed up 2.2 percent.
3M closed up 5.2 percent after posting quarterly results that beat on both the top and bottom line. The conglomerate said recent restructuring moves have made its operation more efficient and positioned it for long-term success.
Energy closed up nearly 3.8 percent to lead all S&P 500 sectors higher and push the index above the psychologically key 1,900 level in the close.
U.S. crude oil settled up $1.11, or 3.66 percent, at $31.45 a barrel, well off session highs of over $32 a barrel. Earlier, Brent briefly climbed 7 percent to top $32.50 a barrel. The gains came amid news OPEC is making renewed calls for rival producers to cut supply alongside its members.
The Nasdaq composite closed up nearly 1.1 percent as Apple reversed earlier losses to close about half a percent higher, while the iShares Nasdaq Biotechnology ETF (IBB) pared an intraday 2 percent decline to close 0.4 percent lower. Earlier, declines in both Apple and IBB briefly dragged the Nasdaq composite into negative territory.
Apple is scheduled to report after the closing bell, while DuPont, Procter & Gamble and Sprint were among those announcing results ahead of the open.
"I think it will be all about earnings and maybe this time earnings can trump oil if it's moving higher," said Peter Cardillo, chief market economist at First Standard Financial.
Read MoreCould Apple turn the tide for stocks?
The Federal Open Market Committee kicked off its two-day meeting Tuesday and is scheduled to release its statement Wednesday afternoon. No change in rates is expected but investors will be scrutinizing the statement for insight into policymakers' views on the economic environment and the future path of tightening.
"I think markets are maybe betting and hoping there will be dovish commentary from the Fed tomorrow. .. If they acknowledge the tightening of the financial conditions and softening in growth people will take them as acknowledging four hikes are off the table," said Peter Boockvar, chief market analyst at The Lindsey Group.
Boockvar and other analysts also attributed some of the gains in stocks to stabilization in commodities, with copper rising to its highest in two weeks.
China's General Administration of Customs said Tuesday that refined copper imports in December rose 34 percent year-over-year, for the fourth consecutive month of strong imports, Dow Jones reported.
"This is an encouraging sign for the copper market but it's likely a peak in the near term," said Dane Davis, commodities research analyst at Barclays.
In economic news, the flash Markit Services PMI for January came in at 53.7, versus the final 54.3 December print.
Consumer confidence was 98.1, up from a slightly downwardly revised December read of 96.3.
The January Richmond Fed Manufacturing Index was 2, versus 6 in December.
Earlier, the S&P/Case-Shiller 20-City Composite rose 5.8 percent year-over-year in November, topping expectations and faster than the 5.5-percent increase in October.
The November FHFA House Price Index rose 0.5 percent from the previous month, or 5.9 percent year-over-year.
Treasury yields held lower, with the 2-year yield near 0.84 percent and the 10-year yield at 2.00 percent.
"I think bonds are rallying too much," said Lawrence McDonald, head of the U.S. Macro Strategies group at Société Générale. He said the Fed statement will likely be more hawkish than markets expect since Fed Chair Janet Yellen is scheduled to testify before Congress in about two weeks — the first of her semi-annual testimonies since the central bank raised rates in December.
The Treasury auctioned 2-year notes at a high yield of 0.86 percent. The bid-to-cover ratio was 2.90 versus the average 3.23, according to StreetAccount.
The U.S. dollar held about 0.3 percent lower against major world currencies, with the euro above $1.08 and the yen at 118.46 yen against the greenback.
In Europe, stocks closed higher as oil bounced. Asian stocks closed sharply lower, with the Shanghai Composite plunging 6.4 percent to its lowest since late 2014. The Nikkei 225 lost 2.35 percent.
The Shanghai index had its worst day since the suspension of the circuit breaker rule in early January. Traders noted a variety of factors behind the sharp decline in Chinese equities, including renewed concerns about capital outflows and disappointment with central bank action thus far.