U.S. stocks closed higher on Tuesday after a choppy trading session as investors eyed developments in the Greece debt crisis and the start of corporate earnings season. (Tweet This)
The S&P 500 fell below its 200-day moving average for its first time since October 20 before trading as high as 15.02 points up.
"We broke the 200 day moving average ... and around that time the market began to stabilize," said Robert Pavlik chief market strategist at Boston Private Wealth, adding that the S&P 500 also hit a support level of 2,045 and has since bounced back.
The index closed up 12.58 points, or 0.61 percent, at 2,081.34, with materials being the only laggard utilities and consumer staples leading advancers. In fact, consumer staples had their best day of 2015, rising 2 percent for the first time since December 18.
"I think there are two factors here: one is a technical bonce on the S&P from the 2,045 support level and another is the [International Monetary Fund] warning the Fed not to raise rates again," said Peter Cardillo, chief market economist at Rockwell Capital.
The IMF reiterated that the Federal Reserve should not raise interest rates until 2016 on Tuesday.
The Dow Jones Industrial Average ended 93.33 points higher, or 0.53 percent, at 17,776.9, with E.I. du Pont leading decliners and Coca-Cola and Procter & Gamble the biggest advancers. At their lows, blue-chip stocks traded down 217.9 points, while rising as much as 109.87 points.
The Nasdaq closed up 5.52 points, or 0.11 percent, at 4,997.46. The index traded down as much as 89.73 points before coming back to positive territory.
In morning trade, the major averages opened higher but quickly turned lower, weighted down by Greece news.
Euro zone leaders held an emergency summit in Brussels to discuss Greece. The European Union later said all 28 of its heads of state will convene to discuss Greece's situation on Sunday.
"We're sort of in an news vacuum and all the attention is on [Greece]," said William Lynch, director of investments at Hindsdale Associates.
Greece will submit a new aid proposal to European creditors "maybe" on Wednesday, euro zone officials said, with Athens' European partners convening in Brussels for emergency talks.
However, the government's latest proposals differ only slightly from previous versions, German media reported.
Also, a senior French official said the euro zone is weighing a plan for a short-term deal between Greece and its creditors.
Investors are also preparing for the the start of earnings season, as Alcoa is scheduled to released quarterly results Wednesday after the bell.
"I think second-quarter earnings will be more important than what first quarter earnings and what third quarter earnings will be" because they will show hot companies are coping with the appreciation of the dollar, said Maris Ogg, president at Tower Bridge Advisors.
Ogg added that, if Q2 earnings do not disappoint, investors will start formulating their 2016 outlooks.
"Overall, earnings are expected to be fairly weak" because of the weakness shown in Q1 earnings, Lynch said.
In U.S. economic data, May international trade numbers showed that the U.S. trade deficit widened, fueled by a drop in exports.
Bond yields continued to fall, with the U.S. 10-year yield below 2.20 percent, before trading around 2.26 percent and the 2-year note yielded 0.58 percent. The German 10-year bund yield was 0.64 percent.
The dollar gained nearly 1 percent, while the euro hit a low of $1.0915, its lowest since June 2, before trading 0.38 percent higher against the single currency.
The JOLTS job openings data came in slightly higher for May than the previous month. Consumer credit figures are due at 3 p.m. The U.S. Treasury is scheduled to hold a three-year note auction later in the day.
The Federal Reserve releases its meeting minutes Wednesday afternoon.
The benchmark Shanghai Composite fell more than 1 percent amid doubts that steps taken by Beijing in the past week would shore up battered stock markets.
Oil futures closed down just 20 cents at $52.33 per barrel after trading down about 1 percent for most of the session. On Monday, U.S. crude futures ended nearly 8 percent lower.
Decliners were a slight step ahead of advancers on the New York Stock Exchange, with an exchange volume of 622 million and a composite volume of 3.12 billion.
Gold futures settled down $20.60 to $1,152.60 an ounce.
On tap this week:
Earnings: Alcoa, WD-40
1 p.m.: $21 billion 10-year note auction
2 p.m.: FOMC minutes
2 p.m.: San Francisco Fed President John Williams
Earnings: Pepsico, Walgreens Boots Alliance, PriceSmart, Cintas, Barracuda Networks
6:45 a.m.: Minneapolis Fed President Narayana Kocherlakota in Frankfurt
8:30 a.m.: Initial claims
10:15 a.m.: Fed Gov. Lael Brainard
1 p.m.: $13 billion 30-year bond auction
12:30 p.m.: Kansas City Fed President Esther George on economy and policy
10 a.m.: Wholesale trade
11:35 a.m.: Boston Fed President Eric Rosengren
12:30 p.m.: Fed Chair Janet Yellen on economy
More From CNBC.com: