(Adds close of U.S. markets)
By Herbert Lash
NEW YORK, May 6 (Reuters) - Oil shot to a record over $122 a barrel on Tuesday, and U.S. stocks rose on energy-related shares and a gain in Microsoft over speculation it would resume takeover talks with Yahoo that fell apart.
Crude oil extended a rally that has seen prices double over the past year as Goldman Sachs forecast oil could hit $200 as part of a "super-spike" driven by a lack of adequate supply.
The price of U.S. 10-year Treasury notes dipped, erasing earlier gains, as reassuring comments from Fannie Mae <FNM.N>, the largest provider of U.S. home financing, helped send stocks higher and dimmed bonds' safe-haven appeal.
Fannie Mae executives were cautiously optimistic that the worst of a credit crisis that erupted from a housing market slump may have passed. That triggered a big rally in Fannie Mae shares and supported a wider advance in U.S. stocks.
The dollar extended declines against the euro and other major currencies for a second day, and U.S. gold futures ended slightly higher after initially scaling a one-week high.
U.S. stocks spent much of the morning underwater after Fannie Mae reported a $2.5 billion loss -- its third quarterly loss in a row. That renewed credit jitters and raised the safe-haven appeal of government debt.
But Fannie Mae shares shed early losses to turn higher as the tone of company executives on a conference call reassured investors, analysts said. Fannie Mae said it is improving its mortgage portfolio and shareholder value with the housing market in the middle of a down cycle.
"Whatever comments they're making are making people more comfortable," said Bobby Harrington, head of block trading at UBS.
Fannie Mae shares surged 8.6 percent.
The company earlier cut its dividend and set plans to raise $6 billion in fresh funds to weather the U.S. housing market slump.
The Nasdaq Composite Index briefly rose 1 percent in late trading as investors anticipated that Yahoo Inc may give in to pressure from its largest shareholders to reconsider Microsoft Corp's $47.5 billion offer.
Investors also noted conciliatory comments from Yahoo's chief executive, Jerry Yang.
Yahoo shares rose 4.4 percent, partially recovering from a 15 percent slide on Monday after Microsoft withdrew its bid to create a stronger competitor to Google Inc <GOOG.O>.
Microsoft rose 1.6 percent and Google was down 0.8 percent.
The Dow Jones industrial average <
> rose 51.29 points, or 0.4 percent, to close at 13,020.83. The Standard & Poor's 500 Index <.SPX> added 10.77 points, or 0.77 percent, to finish at 1,418.26. The Nasdaq Composite Index < > gained 19.19 points, or 0.78 percent, to end at 2,483.31.Banks and insurers put European shares under pressure after UBS <UBSN.VX> sought to purge the ill effects of the credit crisis and Swiss Re <RUKN.VX> announced another round of write-downs.
UBS shares fell 4.5 percent and were the biggest drag on the broader European equity market.
The FTSEurofirst 300 index <
> of top European shares closed down 0.5 percent at 1,351.25 points, having recovered from a decline of as much as 1.1 percent as stocks on Wall Street pared losses. The index has rallied about 13 percent since hitting near-three year lows in mid-March."A bear market rally usually lasts 35 days and (rises) an average of 12 to 13 percent, that is exactly what we've seen on the S&P, so this would be it," said Philippe Gijsels, a senior equities strategist at Fortis Bank in Brussels.
"If this is a bear market rally, it should stop around now."
Oil prices jumped on supply concerns spurred by rising tensions with Iran and disruptions in Nigeria.
U.S. crude <CLc1> settled up $1.87 at $121.84 a barrel after touching a record $122.73 earlier. London Brent crude <LCOc1> gained $2.32 to $120.31 a barrel, after hitting a record $120.99.
The dollar fell against major trading-partner currencies, with the U.S. Dollar Index <.DXY> down 0.25 percent at 72.999.
The euro <EUR=> rose 0.23 percent to $1.5526. Against the yen, the dollar <JPY=> fell 0.16 percent to 104.70.
U.S. gold futures ended slightly higher after initially scaling a one-week high. Bullion could run into heavy chart-based resistance in the near term, analysts said.
The June contract <GCM8> for gold in New York settled up $3.60 at $877.70 an ounce.
U.S. Treasury debt prices were mixed. The benchmark 10-year U.S. Treasury note <US10YT=RR> fell 8/32 to yield 3.90 percent. The two-year U.S. Treasury note <US2YT=RR> rose 2/32 to yield 2.38 percent. The 30-year U.S. Treasury bond <US30YT=RR> fell 16/32 to yield 4.64 percent.
Stock markets in Hong Kong <
>, China < > and Singapore <.FTSTI> were little changed. The main index in Australia < >, where the central bank kept interest rates steady at a 12-year high and pointed to a slowdown in demand, retreated 0.5 percent.Japan's exchange was closed for a holiday. (Additonal reporting by Caroline Valetkevitch, Richard Leong and Nick Olivari in New York, and Jane Merriman, Amanda Cooper and Atul Prakash in London; Editing by Jonathan Oatis)