Energy stocks were the day's winners, with the S&P energy index up 0.5 percent. The S&P financial sector index was the biggest decliner, down 0.4 percent.

The United States said it is considering air strikes and cooperation with its arch-enemy, Iran, to help the Iraqi government fend off an Islamist insurgency.

"Iraq is an excuse at this point for investors to sell at these levels. As soon as there is some selling, buyers come in almost immediately, and that is why the market is choppy like today," said Peter Cardillo, chief market economist at Rockwell Global Capital in New York.

"It's a further indication that this is not a market that will just plunge on geopolitical issues."

On the merger front, medical device maker Medtronic Inc agreed to buy Dublin-based Covidien Plc for $42.9 billion and shift its executive headquarters to Ireland in the latest move by U.S. companies to take advantage of lower tax rates abroad. Medtronic shares slid 1.1 percent to $60.03. In contrast, Covidien's stock shot up 20.5 percent to $86.75; it was the S&P 500's biggest percentage gainer.

The Dow Jones industrial average rose 5.27 points or 0.03 percent, to end at 16,781.01. The S&P 500 gained 1.62 points or 0.08 percent, to 1,937.78. The Nasdaq Composite added 10.45 points or 0.24 percent, to 4,321.11.

Williams Companies jumped 18.7 percent to $56.02. The stock was the S&P 500's second-biggest percentage gainer. The pipeline operator said it agreed to acquire control of Access Midstream Partners LP for $5.99 billion as the first step toward merging it with its operations.

Level 3 Communications said it would buy Internet services provider tw telecom Inc for $40.86 per share in a cash-and-stock deal. Level 3 shares fell 4.1 percent to $42.30, while tw telecom's stock rose 7.3 percent to $38.99.

Fusion-io Inc FIO.N shares soared 22.4 percent to $11.36 after SanDisk Corp said it will buy the company for about $1.1 billion to boost its flash storage drive business. SanDisk rose 3.6 percent to $102.00.

Crude oil futures rose in choppy trading as advances by Sunni insurgents in Iraq fed concerns about a potential disruption to oil exports from the second-largest OPEC producer.

Brent crude for August delivery LCOc1 rose 48 cents to settle at $112.94 a barrel, off an intraday high of $113.28.

The CBOE Crude Oil ETF Volatility Index surged nearly 35 percent last week. It rose 0.3 percent on Monday to 19.52.

Economic data was positive. Manufacturing output rose in May and factory activity in New York state accelerated sharply this month, buoying hopes of a strong rebound in economic growth this quarter.

Volume was around 5.28 billion shares on U.S. exchanges, slightly below last month's average of about 5.76 billion, according to data from BATS Global Markets.

(Reporting by Angela Moon; Editing by Jan Paschal)

By Angela Moon