Stocks rallied on Tuesday in a volatile session as investors struggled to decipher the Fed's signals on the economy after a dizzying two-week slide.

Buying accelerated into the close and the S&P 500 posted its best day in more than two years, following a drop of nearly 17 percent over the past weeks.

The market reversed direction six times after a Fed statement that pledged two more years of near-zero interest rates.

Bank shares roared back from recent losses with the KBW capital markets index up 6.7 percent.

The last three or four weeks, the stock market has really discounted a mild recession, said Mohannad Aama, managing director at Beam Capital Management LLC in New York.

Now after the Fed announcement, the market has to start factoring in what the response from the Fed and the government will be. There is still a small chance for a fiscal stimulus aimed at job creation. The FOMC statement today was positive for equities.

The Dow Jones industrial average gained 429.92 points, or 3.98 percent, to end at 11,239.77. The Standard & Poor's 500 Index rose 53.07 points, or 4.74 percent, to 1,172.53. The Nasdaq Composite Index added 124.83 points, or 5.29 percent, to 2,482.52.

About 16.4 billion shares traded on the New York Stock Exchange, NYSE Amex and Nasdaq -- more than twice the daily average so far this year of 7.75 billion.

Advancing stocks outnumbered declining ones on the NYSE by a ratio of almost 12 to 1, while on the Nasdaq, almost five stocks rose for every one that fell.

The three major U.S. stock indexes, though, are still in negative territory for the year, in spite of Tuesday's strong rally.

At its session low after the Fed statement, the S&P 500 came within a few points of entering a bear market -- or a 20 percent decline from its recent closing high set on April 29.

According to a Reuters poll, the United States faces one-in-four odds of slipping back into recession, though the economic outlook was seen as raising the likelihood of new Fed action.

Even some investors hoping for action from the Fed acknowledged the central bank's options appear to be limited because the current crisis is not liquidity-driven, as it was in 2008.

Equities suffered a massive drop on Monday, the first session since the United States lost its top-tier triple-A credit rating from Standard & Poor's. As a result of Monday's huge sell-off, the S&P 500 posted its worst one-day percentage loss since December 2008.

(Additional reporting by Chuck Mikolajczak; Editing by Jan Paschal)