Stocks closed little changed on Tuesday after President Donald Trump announced he was withdrawing the U.S. from the Iran nuclear deal signed three years ago.

The Dow Jones industrial average finished 2.89 points higher at 24,360.21, with J.P. Morgan Chase as the best-performing stock in the index. The 30-stock index briefly fell more than 150 points following the announcement.

The closed just below breakeven at 2,671.92 as utilities fell 2.5 percent. The Nasdaq composite eked out a small gain to close at 7,266.90.

Back in 2015, the Obama administration and Iran signed a deal to defer sanctions on Iranian oil exports, while Iran curbed its nuclear program. On Tuesday, Trump said the U.S. was pulling out of that deal and restoring sanctions.

Crude settled 2.4 percent lower at $69.06 per barrel and briefly fell more than 3 percent.

"If financials weren't performing well today, we'd be looking at a much darker picture," said JJ Kinahan, chief market strategist at TD Ameritrade. "If you look at the rest of the board, things are kind of pink."

The finanicals sector was one of four that closed higher on Tuesday, climbing 0.7 percent. Industrials also rose, as shares of defense companies jumped. The iShares U.S. Aerospace & Defense ETF (ITA) rose 1.5 percent, its best day since March 26, when it surged 2.6 percent.

Quincy Krosby, chief market strategist at Prudential Financial, said the market will view the announcement as preview on " how he deals with other foreign policy matters such as North Korea."