NEW YORK ( TheStreet) -- Stocks staged a mighty rally Tuesday, even shrugging off the uncertainty presented by a rare East Coast earthquake, as all three major U.S. equity indices gained at least 3%.

Early buying was attributed to positive global economic data, which overshadowed another weak read on the U.S. housing market, as well as growing investor optimism about a high-profile speech due from Fed Chairman Ben Bernanke at the end of the week. The gains accelerated ahead of the close after the S&P 500 broke past 1150, a key technical threshold.

Speculation that Bernanke will lay out a plan for the central bank to support the economy on Friday was a positive, along with promising news that the number of "problem" banks had shrunk for the first time since the financial crisis. Furthermore, no major negative headlines came out from the eurozone.

When the closing bell sounded, the Dow Jones Industrial Average was up 322 points, almost 3%, at 11,171. The S&P 500 finished ahead 39 points, or 3.4%, at 1162, and the Nasdaq closed up 101 points, or 4.3%, at 2446.

The 5.9 magnitude earthquake in Virginia put a slight dent in the Dow mid-afternoon, but the blue-chip index still finished just below its session high of 11,176. The sustained momentum was in stark contrast to Monday's action, which saw the Dow slowly surrender early gains throughout the afternoon.

"Since last Thursday, the S&P 500 has tried to break above 1150. Crossing that today is giving people a better mood in terms of the technical," said Chris Johnson, chief investment strategist at Johnson Research Group. "There may not be a jump right up to 1200 but at least this is a relief rally."

Johnson added that the situation in Libya has also given investors a reason to feel positive. "It's not a fundamental improvement but the market was tired of getting beat up," he explained.

The chatter about Bernanke's speech at the Kansas City Fed's annual economic conference in Jackson Hole, Wy., on Friday will provide a backdrop for stock action the rest of the week. Although most market watchers don't expect Bernanke to signal another quantitative easing program as he did at the symposium last year, many believe he will at least shed further light on the Fed's stance on how it could help given the inflationary pressures in the current economy.

The Federal Deposit Insurance Corp. took 23 institutions off their "problem list," marking the first decline in that list of more than 800 banks since 2006. While this news suggested that fewer institutions are at risk of failing, fears about mortgage-related assets and falling revenues continue to plague the financial sector.

Encouraging economic data out of China gave a lift to global markets earlier. A purchasing managers index showed that manufacturing activity in China contracted at a slower pace in August than economists expected.

Meanwhile, manufacturing activity in Germany also came in better-than-expected . A purchasing managers index for the eurozone, however, remained near a two-year low for August, confirming stagnated growth in the region.

The FTSE in London added 0.7% and the DAX in Frankfurt gained 1.1%. Hong Kong's Hang Seng jumped 2% and Japan's Nikkei advanced 1.2%.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Technology and energy stocks led the rally with Exxon Mobil ( XOM), Chevron ( CVX), IBM ( IBM) and Microsoft ( MSFT) trading near the top of the Dow.

Of the 4 billion shares trading on the New York Stock Exchange, 80% rose while 20% fell. Some 1.7 billion stocks changed hands on the Nasdaq.

The mildest gains were seen across the utilities and basic materials sectors. Amid broad gains, Bank of America ( BAC), Walt Disney ( DIS), and Travelers ( TRV) were the only Dow components that closed in the red.

In U.S. economic news, a decrease in new home sales for the third month in a row disappointed economists. New-home sales fell by 0.7% in June compared to a forecasted 0.6% decline. The housing industry is expected to remain a drag on the economy.

Global manufacturing data helped to lift oil prices . The October crude oil contract gained $1.02 to settle at $85.44 a barrel. Gold was declining after hitting a record high of $1,917.60 an ounce as the equities rally gained momentum. The December delivery contract lost $30 to $1,858 an ounce.

Deven Sharma, president of McGraw-Hill ( MHP) subsidiary Standard & Poor's, will leave the company and be replaced by Douglas Peterson . Peterson, who will join the company Sept. 12, is currently chief operating officer of Citibank N.A., the chief banking unit of Citigroup ( C).

Sharma's resignation follows the rating agency's much-criticized decision to downgrade the U.S. credit rating to AA+ from AAA. McGraw-Hill's stock moved up 4.5% to 38.69.

Delta ( DAL) plans to order 100 Boeing ( BA) 737 single-aisle jets in a deal valued at more than $8 billion , according to a Wall Street Journal report. Boeing's stock gained 4% to $60.77.

H.J. Heinz ( HNZ) reported better-than-expected first-quarter adjusted earnings on growth across emerging markets . The company expects second-quarter earnings to meet or come in slightly above its year-ago profit, but lowered its fiscal 2012 adjusted earnings guidance. The stock lost 1.2% to $51.44.

Shares of UBS ( UBS) climbed 5.2% to $13.88 following news that the Swiss bank plans to cut 3,500 jobs in an effort to eliminate expenses of 2 billion Swiss francs ($2.54 billion) a year by the end of 2013.

The benchmark 10-year Treasury was down 2/32, lifting the yield to 2.118%. The dollar weakened against a basket of currencies, with the dollar index down by 0.4%.

-- Written by Chao Deng in New York.