U.S. stocks closed lower on Tuesday, pulling back from record highs set earlier in the session, as investors weighed the possibility of a government shutdown.

The Dow Jones industrial average ended 10.33 points lower at 25,792.86. At its session highs, the index traded above 26,000 and 283 points higher. The Dow also posted its biggest one-day reversal since Feb. 10, 2016.

The closed 0.4 percent lower at 2,776.42. The index had traded above 2,800 for the first time earlier in the session. The Nasdaq composite also erased gains, finishing 0.5 percent lower at 7,223.69.

Congress needs to pass a spending bill by the end of Friday to avoid a government shutdown. A point of contention between Republicans and Democrats is an immigration bill which Democrats want to pass. Those talks have complicated efforts to keep the government open.

"Key Democratic constituencies are demanding that Congressional Democrats insist on making DACA part of the 'must pass' budget legislation to keep the government open," said L. Thomas Block, Washington policy strategist at Fundstrat Global Advisors.

"DACA is actually the easy issue for a budget compromise. More difficult is needed legislation to avoid defense and non-defense spending cuts under the sequestration required by the Budget Act of 2011," Block said.

The Cboe Volatility index, which is considered to be the best gauge of fear in the market, rose 14.5 percent to 11.63.



Historically, stocks have struggled immediately after a government shutdown. The S&P 500 averages a negative return of 0.3 percent one week after the government shuts down, according to CNBC analysis using Kensho.

"I think the market has been conditioned to a last minute deal. I think the market can actually continue to focus on the earnings," said Quincy Krosby, chief market strategist at Prudential Financial. "Anything that throws that off is going to be a net negative for the market but because it will be indicative of ability of the two sides together to get there, and that will be a deeper concern."

Equities were boosted earlier by better-than-expected earnings and rising economic optimism under President Donald Trump.

UnitedHealth posted better-than-expected earnings and sales, sending the stock up 1.9 percent. Citigroup reported adjusted earnings that surpassed estimates, while revenue came in line with expectations. Citigroup shares rose 0.4 percent.

Earnings season is off to a strong start thus far. Of the S&P 500 companies that had reported as of Friday, 69 percent have surpassed earnings-per-share estimates while 85 percent have beaten expectations on the top line, according to FactSet.

Equities are off to a strong start for the year, with the Dow, S&P 500 and Nasdaq composite jumping at least 3.8 percent in 2018. A stronger U.S. economy, tax reform, and optimism maid the corporate earnings season have been key catalysts for the market.

"The boring stock market of 2017 has turned on the burners two weeks into the new year," said Frank Cappelleri, executive director at Instinet, noting the S&P 500 was on track to post its first monthly gain of more than 4 percent since March 2016.

"Regardless if the [S&P 500] finishes January with a 4% gain or not, this just tells us once again that strength does, in fact, beget more strength. It also means we shouldn't cast doubt on the uptrend simply because the advance has gained steam recently," Cappelleri said in a note.

The major averages closed at record highs on Friday. U.S. markets were closed on Monday because of the Martin Luther King holiday.

The euro, meanwhile, hovered near a three-year peak amid heightened expectations the European Central Bank may soon pare its monetary stimulus. The U.S. dollar had been showing some signs of weakness in recent sessions.

Elsewhere, Merck shares jumped 5.8 percent after announcing positive Phase 3 results for its Keytruda drug, which is aimed at treating cancer.

Disclosure: NBCUniversal, parent of CNBC, is a minority investor in Kensho.

—CNBC's Patti Domm and Robert Hum contributed to this report.