(Updates to midday, changes byline)
By Cal Mankowski
NEW YORK, May 6 (Reuters) - U.S. stocks edged higher on Tuesday after speculation that Microsoft and Yahoo will resume merger talks and comments from housing finance company Fannie Mae reassured investors about its financial condition.
Before the opening bell, Fannie Mae <FNM.N>, the largest provider of U.S. home financing, reported a net $2.5 billion loss and said it sees significant credit losses into 2009. The company also cut its dividend.
Shares of Fannie Mae and its smaller rival, Freddie Mac, opened sharply lower but changed course and posted strong gains after Fannie's positive comments on a conference call.
Microsoft Corp <MSFT.0> and Yahoo Inc <YHOO.O> both rose as speculation continued that pressure from Yahoo's shareholders would bring about renewed merger talks and an eventual deal. Microsoft shares gained 1.4 percent to $29.50 while Yahoo jumped nearly 6 percent to $25.81, making them among the Nasdaq's top positive movers.
"It seems like the shareholders are going to try to make something happen, but the stock is acting like that's real," said Bobby Harrington, head of block trading at UBS in Stamford, Connecticut.
The Dow Jones industrial average <
> rose 1.71 points, or 0.01 percent, at 12,971.25. The Standard & Poor's 500 Index <.SPX> gained 4.58 points, or 0.33 percent, to 1,412.07. The Nasdaq Composite Index < > climbed 9.71 points, or 0.39 percent, to 2,473.83.Fannie Mae shares climbed 6.2 percent to $30.04 and Freddie Mac shares advanced 5.2 percent to $26.85. Moody's Investors Service affirmed Fannie's "Aaa" senior debt rating.
Elsewhere in the financial sector, the credit crunch and its related problems continued to weigh.
Money manager Legg Mason Inc <LM.N> posted a quarterly loss, merger adviser Lazard Ltd <LAZ.N> reported a 71 percent drop in earnings and Swiss bank UBS <UBSN.VX> said it will cut 5,500 employees because of subprime and other credit losses.
Legg Mason shares were down 6.3 percent at $58.78. Lazard's stock fell 6.3 percent to $35.13.
Banking stocks were already rattled on Monday by doubts about Bank of America's <BAC.N> takeover of troubled mortgage lender Countrywide Financial Corp <CFC.N>. Late on Monday, Bank of America said it remains committed to the takeover deal.
At midday, Bank of America's stock was up 0.5 percent at $39.18, reversing an earlier decline, while Countrywide's stock was down 1.7 percent at $5.45.
The S&P financial sector index <.GSPF>, which fell in early trading, changed course and shot up 1.8 percent.
Energy shares extended Monday's gains after Anadarko Petroleum <APC.N> posted better-than-expected earnings late on Monday and crude oil futures surged on Tuesday to hit a record above $122 per barrel.
Anadarko shares jumped 9.3 percent to $74.39. Hess Corp <HES.N> shares were another top gainer in the oil patch, rising 6.8 percent to $115.60.
Crude's higher price pummeled airline stocks for a second straight session. The American Stock Exchange index of airlines' shares <.XAL> slid 3.2 percent. Its worst performer was UAL Corp <UAUA.O>, the operator of United Airlines, which fell 7.1 percent to $13.93. (Additional reporting by Jennifer Coogan) (Reporting by Cal Mankowski; Editing by Jan Paschal)