By Anora Mahmudova, MarketWatch

NEW YORK (MarketWatch) -- U.S. stocks ended Tuesday slightly higher, with the main benchmarks gaining for the third consecutive day. However, gains were muted as headlines of violence in Iraq did not abate.

After the initial wobble, investors shrugged off mildly disappointing economic reports on inflation and the housing market.

Consumer prices rose sharply in May, while a number of housing starts declined by more than expected. Meanwhile in Iraq, government forces fought with militant rebels, killing 28 ISIS fighters, according to the Wall Street Journal report.

The S&P 500 (SPX) closed 4.21 points, or 0.2%, higher at 1,941.99. The Dow Jones Industrial Average (DJI) added 27.48 points, or 0.2%, to 16,808.49.

The Nasdaq Composite (RIXF) ended the day up 16.13 points, or 0.4% at 4,337.23. The Russell 2000 (RUT) closed 9.8 points, or 0.8%, higher at 1,176.62, according to preliminary results on FactSet.

Follow MarketWatch's live blog of today's stock-market action.

Liz Ann Sonders, chief investment strategist at Charles Schwab said that even with the tick-up in the inflation rate, it remains below the Fed's target.

"Today's CPI data was slightly higher than expected and did not come to us as a big surprise, but certainly the uptick sparked fears of a possible risk of inflation," Sonder said.

"On the housing starts, while the headline number was disappointing, the less noisy year-over-year trend is still improving. There are more housing starts this year then there were last year and that's a positive," she added.

In economic news, U.S. consumer prices rose sharply in May for the second straight month, prompting fears that the Federal Reserve may begin tightening the monetary policy sooner than the markets are expecting.

Construction on new U.S. homes fell by 6.5% in May and builders trimmed plans for future projects in another sign that a hoped-for spring revival in the housing market remains elusive.

Officials at the Federal Open Markets Committee began their two-day policy-setting meeting.

Read: What brokerages are saying about the FOMC meeting on Wednesday.

* In corporate news, Nuance Communications Inc. shares climbed 2.5% after reports on Monday that the speech-recognition software maker had held talks with suitors, including Samsung Electronics Co. and private equity funds. Nuance shares are up over 27% this year so far. Tesla Motors Inc. shares rose 3.1% building on an 8.8% gain in the previous session over reports about a possible collaboration with its competitors. Tesla shares have climbed 53% year to date. Shares of Gentiva Health Services Inc. rallied 5.2% after Kindred Healthcare Inc. sweetened its bid for the home-health and hospice company. Shares in E-Trade Financial Corp and Charles Schwab Corp rallied 7.7% and 5.5% respectively with the Senate hearing on whether high-frequency trading hurts the markets.

* In overseas equity markets, European stocks closed higher. Asian stock were mostly lower, but the Nikkei bucked the trend and finished higher.

* Among commodities, gold for August delivery fell Tuesday, posting the first loss in seven sessions, as concerns abated slightly about tensions in Iraq, weighing on the flight to safe-haven assets. Oil futures lost ground Tuesday, giving back some recent gains ahead of an update on weekly U.S. supply levels as worries about imminent risks to oil production in Iraq soften.

More must-reads from MarketWatch:

Why the Fed fears Uber

'Flash Boys' hero to take on the exchanges at Senate hearing

7 reasons why you made less than the market

Subscribe to WSJ: http://online.wsj.com?mod=djnwires

Tesla (NASDAQ:TSLA)
Historical Stock Chart
From Mar 2024 to Apr 2024 Click Here for more Tesla Charts.
Tesla (NASDAQ:TSLA)
Historical Stock Chart
From Apr 2023 to Apr 2024 Click Here for more Tesla Charts.