(AP) -- The major U.S. stock indexes partially recovered from a daylong slide in the final minutes of trading Tuesday to finish essentially flat.
The indexes had been drifting slightly lower as investors weighed the Trump administration's decision to withdraw from a 2015 nuclear deal with Iran and reinstate sanctions on the country.
The policy change, announced in an afternoon speech by President Donald Trump, had been largely expected by traders, who sent crude oil prices sliding more than 2 percent a day after crude reached above $70 a barrel for the first time in more than three years.
Health care, utilities and consumer-goods companies were among the biggest decliners. Banks, technology stocks and industrials posted gains. Energy sector companies also eked out a gain after being in a slump much of the day on lower oil prices.
"At least for the moment the movement in oil is moderate and seems to be more or less what the market was expecting," said Phil Guarco, global investment specialist, J.P. Morgan Private Bank. "While this is big news, it is not something that the market hadn't already priced in. Now we have to see what the reactions are."
The S&P 500 index dipped 0.71 points, or 0.03 percent, to 2,671.92. The lower close snapped a two-day winning streak for the broad market index. The Dow Jones industrial average gained 2.89 points, or 0.01 percent, to 24,360.21. The Nasdaq rose 1.69 points, or 0.02 percent, to 7,266.90.
Smaller companies fared better than the rest of the market. The Russell 2000 index of smaller-company stocks picked up 7.44 points, or 0.5 percent, to 1,586.39.
The major stock indexes spent much of the day in the red and oil prices slumped as investors awaited Trump's announcement on the U.S.-Iran policy.
In televised remarks, Trump said that the United States was withdrawing from the Iran nuclear deal, which he called "defective at its core." The move reinstalls sanctions on the Iranian regime. The 2015 agreement required Iran to curb its nuclear enrichment program in exchange for relief from international sanctions.
After Trump's remarks, oil prices pared some of their earlier losses. Benchmark U.S. crude oil fell $1.67, or 2.4 percent, to $69.06 per barrel in New York. Uncertainty over whether the U.S. would pull out of the Iran pact helped lift the price of crude on Monday above $70 a barrel for the first time since November 2014.
On Tuesday, Brent crude, which is used to price international oils, lost $1.32, or 1.7 percent, to $74.85 per barrel in London.
So why didn't prices keep climbing Tuesday?
"It's all really in the expectations," Guarco said. "The market was pricing in something even more aggressive. Still, things are very fluid and oil markets could turn on a dime if it seemed that the potential for a supply disruption got meaningfully larger."
Energy stocks mostly reversed an early tumble. Marathon Oil led the gainers, rising 3.4 percent to $20.44.
Several companies, including Airbus, Boeing and Total, that have struck business deals in Iran and could be looking for exemptions from U.S. sanctions, finished slightly lower. Boeing fell 0.6 percent to $338.37, while Total dipped 0.5 percent to $61.67.
Corporate deal news also helped move the market Tuesday.
Shire rose 4.6 percent to $40.35 after the Ireland-based pharmaceutical company agreed to be acquired by Japanese drugmaker Takeda in a deal worth $62.4 billion. Shares in Takeda slipped 0.1 percent to $20.98.
Comcast fell 5.6 percent to $30.59 after Reuters reported that the company wants to make a new offer for the entertainment businesses that Twenty-First Century Fox agreed to sell to Disney. Shares in Fox slipped 0.1 percent to $37.99. Disney slid 0.7 percent to $101.79.
Xcerra gained 3.1 percent to $13.24 after the semiconductor equipment testing company accepted a cash and stock offer valued at $764.4 million from competitor Cohu. Shares in Cohu tumbled 6.3 percent to $21.87.
Bond prices fell. The yield on the 10-year Treasury rose to 2.97 percent from 2.95 percent late Monday. The rise in yields pushed up interest rates, which allows banks to make more money from loans. That helped drive financial sector stocks higher. Capital One Financial rose 1.4 percent to $90.18.
The dollar fell to 109.02 yen from 109.06 yen on Monday. The euro weakened to $1.1858 from $1.1923.
Gold dipped 40 cents to $1,313.70 an ounce. Silver dropped 2 cents to $16.47 an ounce. Copper lost 2 cents to $3.06 a pound.
In other energy futures trading, heating oil fell 3 cents to $2.16 a gallon. Wholesale gasoline lost 2 cents to $2.11 a gallon. Natural gas gave up a penny to $2.73 per 1,000 cubic feet.
Major indexes in Europe finished mostly lower. Germany's DAX dropped 0.3 percent while the CAC 40 in France lost 0.2 percent. Britain's FTSE 100 was flat.
Markets in Asia ended mixed. Japan's Nikkei 225 stock index added 0.2 percent and Hong Kong's Hang Seng index climbed 1.4 percent. South Korea's Kospi gave up early gains to lose 0.5 percent. Shares rose higher in Singapore and Taiwan, but fell 1.9 percent in Indonesia after the government reported economic growth slowed in January-March.