Stocks rose slightly Thursday as a spate of merger news and gains in oil-related stocks offset tepid housing numbers.

The Dow Jones industrial average (search) rose 12.28, or 0.12 percent, to 10,578.65 after moving in and out of positive territory for much of the session. The Dow also inched higher the first three days of the week — an indication that investors, while uninspired by the economic data, are finding few reasons for a big selloff.

The Standard & Poor's 500 index (search) rose 4.35, or 0.36 percent, to 1,210.93, while the Nasdaq composite index (search) closed up 14.23, or 0.69 percent, at 2,089.15.

Energy companies' stocks benefited from the jump in oil prices, with the NYMEX July futures contract jumping $1.01 to settle at $56.58 a barrel on the New York Mercantile Exchange (search) -- less than $2 below the record price of $58.28 a barrel set on April 4.

That prompted investors to buy Exxon Mobil (XOM), as well as the stocks of its rival oil and gas producers Chevron Corp. (CVX), up 2 percent, or $1.08, at $57.92, andConocoPhillips (COP), up 2.2 percent, or $1.27, at $58.60.

Exxon Mobil, Chevron and ConocoPhillips were the three biggest upward influences, in terms of points and percentage gains, on the S&P 500.

Among the biggest deals, Pfizer Inc. (PFE) is buying Vicuron Pharmaceuticals Inc. (MICU), for $1.9 billion, and Integrated Device Technology Inc. (IDTI ) will acquire Integrated Circuit Systems Inc. (ICST) for cash and stock worth $1.7 billion. In addition, nursing-home drug provider Omnicare Inc. (OCR) said it would boost the value of its tender offer for rival NeighborCare Inc. (NCRX) to $1.7 billion from about $1.3 billion.

Analysts said the deals were an indication that stocks remained fairly valued, which can be an inducement for investors to buy.

Shares of Vicuron, which specializes in drugs that fight infection, surged 75 percent to $27.58 on Nasdaq on news of its deal with Pfizer. Blue-chip Pfizer was unchanged at $28.43.

Integrated Circuit was up 12.5 percent to $22.20, while Integrated Device slipped 5.4 percent to $11.86. Both trade on Nasdaq.

Omnicare shares rose 5.6 percent to $40.97 on the NYSE and NeighborCare advanced 4.7 percent to $33.67 on Nasdaq.

Goldman Sachs Group (GS) posted sharply lower quarterly profit. But its shares rose 2.5 percent to $101.66, suggesting that investors were not surprised by the results.

The government reported housing starts edged up 0.2 percent in May, slightly less than expected, but the level of new construction permits remained strong, a sign of continuing strength in the sector.

Jobless claims were up 1,000 to 333,000 in last week, in line with expectations. Recent claim levels have been moderate, but analysts expect auto industry layoffs to send them higher in July.

Stocks are likely to trade in a narrow range until the June 29-30 meeting of the Federal Reserve's policy makers. The Fed is expected to raise short-term interest rates for the ninth time when it meets next, continuing the rate hikes that began last year.

The market's focus will be the Fed's accompanying assessment of the economy; investors are looking for signs that the string of rate hikes is coming to an end.

While Wall Street's conventional wisdom is that rate hikes will end with the Fed's August meeting, some analysts say rate hikes — and the attendant sideways movement that has characterized stocks for the past 17 months — will continue.

"The market is too high, short-term interest rates are too low and long-term interest rates are really low," said Linda Duessel, market strategist and senior portfolio manager at Federated Investors in Pittsburgh, Pa. "The least expected outcome (for stocks) is a strong move up."

Economically sensitive stocks, including raw materials producers, were among the market's best performers Thursday.

"Commodity stocks, which were left for dead two weeks ago, have turned the corner, which indicates that the economy isn't going in the Dumpster like a lot of people think," said Gary Kaltbaum, an independent money manager in Orlando, Fla.

Aluminum maker Alcoa Inc. (AA) was up 37 cents to $27.93, while United States Steel Corp. (X) rose 71 cents to $41.42.

Beleaguered General Motors Corp. (GM) limited the Dow's gains. GM fell 2 percent, or 72 cents, to $35.62. Deutsche Bank said in a research note that GM may not get enough concessions from the United Auto Workers union on health-care costs this year, "which in the context of the recent rally in GM shares may prove disappointing."

Shares of Ford Motor Co. (F) rose 1 percent to $11.27 on the NYSE after Deutsche Bank raised its rating on the carmaker to "hold" from "sell."

Shares of Microchip Technology Inc. (MCHP) were up after Banc of America raised its rating on the chipmaker to "buy" from "neutral." The shares advanced 1.5 percent to $30.

Banc of America also raised its outlook on makers of certain semiconductors to "modest overweight" from "neutral." The Philadelphia Stock Exchange index of semiconductor stocks rose 0.6 percent to 429.64.

Cruise operator Carnival Corp. (CCL) posted 23 percent second-quarter earnings growth. Its shares rose 4 percent to $54.08 on the NYSE.

Trading was moderate on the New York Stock Exchange, with 1.37 billion shares changing hands, below the 1.46 billion daily average for last year.

But Nasdaq trading was active, with about 1.86 billion shares traded -- above the 1.81 billion daily average last year.

Advancers outnumbered decliners on both the New York Stock Exchange and Nasdaq by about 2 to 1.

The Russell 2000 index of smaller companies rose 6.84, or 1.1 percent, to 644.03.

Overseas, Japan's Nikkei stock average rose 0.5 percent. Britain's FTSE 100 was up 25.5 percent, Germany's DAX index was up 31.45 percent and France's CAC-40 was up 0.79.

Reuters and the Associated Press contributed to this report.