Stocks staged a furious late-day rally on Tuesday to push the S&P 500 into positive territory as the focus shifted from European debt woes to buying after shares hit six-month lows.

Major U.S. indexes had fallen more than 3 percent early in the session on growing questions about the stability in the European banking system after the failure of a small Spanish bank over the weekend.

It's a selling climax. This has all the looks to me of a capitulation, said Keith Springer, president of Capital Financial Advisory Services in Sacramento, California.

The S&P briefly fell to its lowest level since early November 2009, down more than 13 percent from its April high.

Strategists linked the rebound in stocks to strengthening in the euro. The single currency earlier fell to an 8 1/2-year low against the yen and approached a 4-year low versus the dollar, while safe-haven U.S. Treasuries rallied.

The Dow Jones industrial average <.DJI> dropped 22.82 points, or 0.23 percent, to 10,043.75. The Standard & Poor's 500 Index <.SPX> gained 0.38 point, or 0.04 percent, to 1,074.03. The Nasdaq Composite Index <.IXIC> shed 2.60 points, or 0.12 percent, to 2,210.95.

Strength in the euro has been a proxy for risk appetite and confidence in the euro zone economy.

European markets fell to their lowest level in nearly nine months as the Libor three-month dollar rate rose to the highest level since July as the Spanish government's rescue of a local bank over the weekend made banks leery of lending to European institutions. Rising Libor rates raise banks' funding costs.

Shares of materials companies and retailers were among the top performers, with the S&P Materials index <.GSPM> up 1.6 percent and the S&P Retail index <.RLX> finishing up 1.4 percent.

AK Steel jumped 11.4 percent to $15.06 after a Citigroup upgrade while AutoZone Inc advanced 5.6 percent to $194.57 after posting third-quarter earnings.

Earlier, the three major U.S. stock indexes had fallen about 3 percent to session lows.

The CBOE Volatility Index <.VIX> or VIX, known as Wall Street's fear gauge, fell 9.1 percent at 34.90 after reaching an earlier high of 43.47, a gain of more than 14 percent.

U.S. consumer confidence rose for the third straight month in May to the highest in more than two years. But that was countered by a report showing single-family home prices dropping in the first quarter on renewed price pressure as federal aid faded away.

Volume was strong with about 13.06 billion shares traded on the New York Stock Exchange, the American Stock Exchange and Nasdaq, well above last year's estimated daily average of 9.65 billion.

Declining stocks outnumbered advancing ones on the NYSE by 1,964 to 1,118, while on the Nasdaq, decliners beat advancers 1,767 to 888.

(Reporting by Chuck Mikolajczak; Editing by Kenneth Barry)