Stocks surged in a broad-based rally on Monday as an agreement on a $1 trillion emergency rescue package quelled fears that Greece's debt crisis would spread.

The package of standby funds and loan guarantees would be available to euro-zone governments shut out of credit markets. The total bailout, reached by European leaders on Monday, is on the scale of the U.S. government's $700 billion Troubled Asset Relief Program in 2008 to stave off the credit crisis.

Banks ranked among the top beneficiaries as the rescue deal reduced fears of a possible default. The S&P Financial index <.GSPF> climbed 5.1 percent and was one of the top percentage gainer among S&P sectors. Bank of America Corp jumped 6.9 percent to $17.30.

The market is telling us that this was the right move, said Marc Pado, U.S. market strategist at Cantor Fitzgerald in San Francisco. The size of the bullet that we dodged here is huge.

Analysts cautioned, however, that longer-term concerns remained over whether euro-zone nations saddled with high debt loads would be able to manage their balance sheets.

As much as no one wanted this to happen, it needed to if we wanted to avoid another crisis like we saw here, Pado said.

The Dow Jones industrial average <.DJI> soared 393.52 points, or 3.79 percent, at 10,773.95. The Standard & Poor's 500 Index <.SPX> rose 45.91 points, or 4.13 percent, at 1,156.79. The Nasdaq Composite Index <.IXIC> gained 98.82 points, or 4.36 percent, at 2,364.46.

The Dow's surge is the biggest intraday move since March 2009, according to Dow Jones Indexes.

Boeing Co was the top boost to the Dow, climbing 6.4 percent to $70.97 after Goldman Sachs raised its rating on the stock to buy from neutral.

McDonald's Corp increased 4 percent to $70.75 after posting a rise in its April same-store sales.

Suntech Power Holdings Co Ltd shot up 11 percent to $11.60 after saying first-quarter revenue would beat Wall Street expectations.

On the downside, Dean Foods Co dropped 24 percent to $11.08 after posting first-quarter earnings that missed estimates and withdrew its full-year profit outlook.

Howard Silverblatt, an analyst at Standard & Poor's, said that based on their records dating back to the late 1960s, the S&P 500's percentage and point gains at the opening were both records.

Advancers outnumbered decliners on the New York Stock Exchange by a ratio of about 30-to-1. On the Nasdaq, more than seven stocks rose for every one that fell.

(Editing by Jeffrey Benkoe)