U.S. stocks closed higher Tuesday, helped by some stabilization in oil prices and recovery in hard-hit areas of the market this year. ( Tweet This )
The Dow Jones industrial average closed up about 166 points after earlier gaining nearly 200 points in afternoon trade. Contributing most to gains, Caterpillar (CAT) closed up about 4.86 percent for its best day since October 5. The stock is one of the worst performers in the Dow year-to-date, down more than 20 percent.
The Dow transports closed up about 1.5 percent as Ryder System (NYSE:R) led nearly all constituents higher.
The S&P 500 closed up nearly 0.9 percent, off session highs of a more than 1 percent rise, with consumer staples, energy, industrials and materials gaining more than 1 percent to lead all 10 sectors higher. Energy is the worst performer in the S&P year-to-date, off more than 20 percent.
The Nasdaq composite closed above the psychologically key 5,000 level for the first time since last Thursday. The index underperformed the other major averages as Apple (AAPL) ended a touch lower and slight declines in Amazon.com (AMZN) and Express Scripts (ESRX) weighed.
Stocks came well off their highs late in the session after New York media reported of a possibility the city had received a credible safety threat. Details on the nature of the threat were not immediately clear, and there was no evidence of an imminent risk to the city.
"You had a market on close sell program of about $400 million and WPIX has reported a credible terrorist threat for New York City," said Art Cashin, director of floor operations at UBS.. He added there were no specifics. "But it's got them nervous."
The New York Police Department said there is no new specific threat to New York City.
The major averages held most of their gains in the close, after a brief dip into negative territory in morning trade.
"In general, if the price of crude stops going down, that takes away some concern," said Marc Chaikin, CEO of Chaikin Analytics. "When you look at what's leading the charge, it's the three sectors that have been weak."
He expects a year-end rally to bring the S&P 500 to 2,080.
U.S. crude settled up 33 cents, or 0.92 percent, at $36.14 a barrel. Brent settled down 24 cents, or 0.66 percent at $36.11 a barrel. The last time brent settled below WTI was in August 2010, although brent did briefly cross below in January of this year. Both commodities remain near multi-year lows.
Analysts also attributed some of the gains in stocks to year-end seasonal factors. U.S. markets close early Thursday, Christmas Eve, and are shut Friday for Christmas Day.
"I would say it's just people looking beyond. I just think people are bottom-fishing here," said James Meyer, chief investment officer at Tower Bridge Advisors.
The Dow Jones industrial average posted its eighth-straight session with a gain or loss of more than 100 points. The index is on pace to break a three-quarter losing streak but is still nearly 2.3 percent lower for the year so far.
DJIA 8-day performance
The S&P 500 is down about 1 percent year-to-date, on track to snap a three-year win streak.
The Nasdaq composite is up 5.6 percent for the year so far.
In economic news, the National Association of Realtors said existing home sales declined 10.5 percent in November, far greater than expected.
"It could be a timing issue related to this new rule (on paperwork). I'm giving the NAR the benefit of the doubt. … I don't think too many people are putting too much stake in what the NAR is saying," said Peter Boockvar, chief market analyst at The Lindsey Group.
"I don't think there's really much left to look at into year-end," Boockvar said, attributing Tuesday's stock moves mostly to "year-end squaring of positions."
The SPDR S&P Homebuilders ETF (XHB) (NYSE Arca: XHB) closed up 0.8 percent.
The final read on third-quarter GDP came in at an annualized rate of 2 percent. Economists polled by Reuters expected annual growth of 1.9 percent, down slightly from the second estimate of 2.1 percent but above the advance estimate of 1.5 percent.
"I think the GDP is being well-received and it just suggests we're going to see solid but modest growth and of course inflation is well-contained and of course the Fed is not likely to be overly aggressive," said Peter Cardillo, chief market economist at First Standard Financial.
The Richmond Fed manufacturing index for December was 6, up from a minus 3 read last month and minus 1 in October.
The U.S. dollar index held mildly lower, with the euro near $1.095 after earlier hitting $1.0984, its highest level against the dollar in nearly a week. The yen was relatively steady near 121 yen against the greenback in the close.
Treasury yields held mildly higher, with the 2-year yield (U.S.:US2Y) at 0.97 percent and the 10-year yield (U.S.:US10Y) near 2.23 percent in afternoon trade.
In corporate news, Nike (NKE) is scheduled to report earnings after the closing bell. The stock closed up 1.58 percent and is the top performer in the Dow year-to-date with gains of more than 35 percent.
Chipotle (CMG) shares continued to fall, hitting a fresh 52-week low and closing down 5.25 percent. JPMorgan downgraded the stock to "neutral" from "overweight" citing the new food safety issues. News broke Monday that the CDC is investigating a different E. coli strain at Chipotle . The stock is down more than 25 percent for the year so far.
The S&P 500 (^GSPC) closed up 17.82 points, or 0.88 percent, at 2,038.97, with consumer staples leading all 10 sectors higher.
The Nasdaq (^IXIC) composite closed up 32.19 points, or 0.65 percent, at 5,001.11.
About three stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 849 million and a composite volume of 3.5 billion in the close.
The CBOE Volatility index (VIX) (^VIX), widely considered the best fear gauge for the market, held near 16.5.
Gold futures settled $6.50 lower, at $1,074.10 per ounce.
—CNBC's Patti Domm contributed to this report.
On tap this week:
7 a.m.: Mortgage applications
8:30 a.m.: Durable goods
8:30 a.m.: Personal income
10 a.m.: New home sales
10 a.m.: Consumer sentiment
11 a.m.: Oil inventories
Stock market closes at 1 p.m.
8:30 a.m.: Initial claims
10:30 a.m.: Natural gas inventories
Christmas Day holiday
*Planner subject to change.
More From CNBC.com:
- Here are the best analysts on Wall Street today
- The secret to financial success in 2016
- Rick Santorum: Why I still have a chance
More From CNBC