Stocks rallied on Thursday and drove the Dow to a record high after Wal-Mart reported better sales, allowing investors to put aside worries over costlier oil and cheaper housing.

The gains in equities, however, took a toll on bonds as investors returned to riskier securities, curbing the safe-haven bid that had lifted Treasuries earlier in the week and pushing benchmark yields to 5.12 percent.

The good news from retailers on monthly sales figures and merger activity in the mining sector drove up the Dow up more than 1 percent to a record high of 13,744.59 points and pushed the Nasdaq to a more than six-year high.

The dollar, meanwhile, dropped to a record low against the euro as troubles in the U.S. mortgage and credit markets continued to dampen the greenback's appeal. The euro was up at $1.3776 after earlier hitting a record high of $1.3799.

A widening trade deficit, which amounted to over $60 billion in May alone, offered little solace to the beleaguered greenback.

Solid results from retailers suggested consumer spending has yet to buckle under the weight of slumping housing prices and rising mortgage defaults.

The surprise of the day is that the consumer is still spending at a healthy rate, said Eric Kuby, chief investment officer, North Star Investment Management Corp. in Chicago.

With weakness in the housing market and overwhelming evidence of a slowdown in the economy, the biggest concern was that we were going to see bad numbers from the retailers, but we're seeing the opposite.

The Dow Jones industrial average was up 158.35 points, or 1.17 percent, at 13,736.22. The Standard & Poor's 500 Index was up 14.05 points, or 0.93 percent, at 1,532.81. The Nasdaq Composite Index was up 22.68 points, or 0.86 percent, at 2,674.47.

Elsewhere, Anglo-Australian miner Rio Tinto Ltd/Plc agreed to buy Canada's Alcan Inc. for $38.1 billion to create the world's biggest aluminum producer, a reminder that the merger boom lives on despite tighter credit conditions.

Still, analysts again nervously eyed the energy markets, where crude Brent oil hit an 11-month high above $77.

They were also anxiously hoping that no further blow-ups would emerge from the subprime mortgage sector, which has affected everyone from lenders to hedge funds.

It seems to me as though the news will get worse on the whole subprime issue, said Stuart Hoffman, chief economist at PNC Financial. The housing market is going to continue to decline, it hasn't hit bottom.

In overseas markets, European stocks snapped two days of losses, boosted by gains in mining, oil and banking shares and supported by Wall Street's gains. The FTSEurofirst 300 closed up 1.2 percent at 1,620.18 points.

In Tokyo, the Nikkei lost 0.36 percent to mark its lowest close in two weeks.