Stock markets staged a massive rally yesterday, soaring as much as 7 percent after the Treasury Department unveiled a plan to help banks purge their balance sheets of toxic assets and home sales made a surprising rebound.

The blue-chip Dow Jones industrial average closed up 6.8 percent, or 497.48 points, to 7775.86. It was the fifth-largest point gain in its history. The broader Standard & Poor's 500-stock index rose 7.1 percent, or 54.38, to 822.92. The tech-heavy Nasdaq jumped 6.8 percent, or 98.50, to 1555.77.

The markets have fluctuated wildly this month, scraping 12-year lows before roaring back to life. Over the past two weeks, the Dow has risen 18.8 percent, the biggest increase since 1938. The S&P's 21.6 percent jump was the largest since 1933.

"I think it's very sustainable," said Bernie McGinn, founder and chief executive of McGinn Investment Management. "I think the direction for the next couple of months is upward."

The gains amount to a show of support by investors for the program to purchase toxic assets, known as the Public-Private Investment Program. It calls for the government to partner with private investors to buy $500 billion to $1 trillion in troubled real-estate-related loans and securities that have poisoned financial institutions and destroyed investor confidence. Those assets would then be auctioned to the highest bidder, removing them from banks' balance sheets.

The financial sector surged on the news, leading yesterday's stock market charge with a nearly 10 percent gain. Citigroup was up 19 percent and Bank of America shot up 26 percent in heavy trading. Wells Fargo was up 24 percent, and J.P. Morgan Chase rose 25 percent.

"You're seeing little rays of hope and positive stories in different sectors," said Jim Dunigan, managing executive of investments for PNC Wealth Management.

Investors also got an unexpected boost yesterday from National Association of Realtors data showing that existing-home sales jumped 5.1 percent in February as more first-time home buyers snapped up cheap homes, a nugget of good news for the beleaguered housing market.

Home sales reached a seasonally adjusted annual rate of 4.72 million in February, confounding analyst expectations that sales would continue to fall, according to the trade group. Plummeting home prices and historically low mortgage rates have attracted more buyers, helping the market recover from its dismal levels in January.

But sales are down nearly 5 percent from the corresponding period a year ago, and the housing sector remains weak, analysts said. Home prices will continue their steep declines in large chunks of the country and it will take months before the market feels the full impact of an $8,000 tax credit for first-time home buyers recently implemented by Congress, they said.

Still, the sales uptick spurred optimism among some analysts that the worst of housing downturn may have passed.

"I think we're very close to the bottom," said Michael T. Darda, chief economist for MKM Partners, a Connecticut research firm. "If we haven't seen it already, it will happen in the next few months."

Sales increased in every part of country in February compared with January, but they rose the most in the Northeast, 15.6 percent. In the Midwest and West, sales were up 1 percent and 2.6 percent, respectively, while in the South, the region that includes Washington, sales increased 6 percent.

With distressed sales, including foreclosures, accounting for 40 to 45 percent of the market, the sales increase came at the expense of home prices, which fell back to 2002 levels, the association said. Median home prices tumbled 15.5 percent, to $165,400, in February from a year ago. Prices have fallen more than 20 percent from their peak in 2006.

There are still far too many houses on the market, according to the industry data, and it would take 9.7 months to sell all of the homes at the current sales rate. The excess capacity, more than 1 million homes, is dragging down prices further and leaving more homeowners owing more on their mortgage than their homes are worth, said Mike Larson, a housing analyst for Weiss Research.

"The market's really trading more on psychology now than fundamentals," said Matthew Eads, portfolio manager and securities analyst for Eads & Heald Investment Counsel. "Investors are really looking for anything to grab on that's a sign of good news."