U.S. 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.6 percent and was the top percentage gainer among S&P sectors. Bank of America Corp surged 6.9 percent to $17.30.

This could've been another situation like when Bear Stearns and Lehman Brothers failed, but the rescue plan shows how serious Europe is about preventing that, said Alan Lancz, president of Alan B. Lancz & Associates, an investment advisory firm, in Toledo, Ohio.

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

We're not totally out of the woods on this issue, but this shows that Europe recognizes how big the problem is, and that's always the first step, Lancz said.

The Dow Jones industrial average <.DJI> was up 416.72 points, or 4.01 percent, at 10,797.15. The Standard & Poor's 500 Index <.SPX> was up 48.59 points, or 4.37 percent, at 1,159.47. The Nasdaq Composite Index <.IXIC> was up 101.16 points, or 4.46 percent, at 2,366.80.

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

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

Boeing Co gave the top boost to the Dow, climbing 6.8 percent to $71.27 after Goldman Sachs raised its recommendation on the stock to buy from neutral.

McDonald's Corp gained 4.3 percent to $70.93 after posting a rise in its April same-store sales.

Suntech Power shot up 10.4 percent to $11.58 after it said its first-quarter revenue would beat Wall Street's expectations.

On the downside, Dean Foods Co plummeted 25.4 percent to $10.91 after it reported first-quarter earnings that missed expectations and withdrew its full-year profit outlook.

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 Jan Paschal)