Stocks climbed on Tuesday, driving the S&P 500 to its best month since October 2002, as investors snapped up top-performing bank and technology shares as the first quarter came to an end.

Upbeat news from Europe set the tone for financials, helping them recover much of Monday's losses and continue a recent robust rally after British bank Barclays (BARC.L) declined to take part in a government asset-protection plan.

Technology shares added to a strong three-week rally after brokerage Davenport recommended investors buy Microsoft Corp (MSFT.O), pointing to increased demand for personal computers in China and the United States, and potential restocking of inventories in Europe.

Even as the broad S&P 500 rose 8.5 percent in March for its best one-month percentage gain since October 2002, uncertainty about the struggling economy left the benchmark U.S. stock index down 11.7 percent for the first quarter.

I don't think this strong rally we've had in March guarantees we will continue this for the rest of the year, said Brian Daley, sales trader at Conifer Securities in New York.

I think there's still a lot of question marks and a lot to be seen in terms of how the fundamentals play out in the second half, and that's what I think investors are really going to focus on.

In fact, data showed business activity in the U.S. Midwest shrank in March at the most severe rate since 1980 while house prices sank a record 19 percent in January from a year earlier.

The Dow Jones industrial average (.DJI) gained 86.90 points, or 1.16 percent, to 7,608.92. The Standard & Poor's 500 Index (.SPX) added 10.34 points, or 1.31 percent, to 797.87. The Nasdaq Composite Index (.IXIC) climbed 26.79 points, or 1.78 percent, to 1,528.59.

S&P'S SIX-QUARTER SLIDE

As the final trading day of March ended, the S&P 500 marked its sixth consecutive quarterly decline, matching the longest streak of quarterly drops that stretched from the end of the fourth quarter of 1968 to the end of the second quarter of 1970. This time, the S&P's cumulative slide for the past six quarters was 47.7 percent, compared with a 30.6 percent drop 39 years ago.

After Monday's sharp sell-off in banking shares on concerns over the sectors health, JPMorgan Chase (JPM.N) rose 7 percent to $26.58 and Bank of America shares (BAC.N) jumped 13.1 percent to $6.82, while the S&P financial index (.GSPF) gained 6.7 percent.

Microsoft shares added 5.1 percent to $18.37 and contributed the most to the Nasdaq's advance.

Alcoa (AA.N) jumped 9.7 percent to $7.34 after Deutsche Bank upgraded the aluminum company's stock to hold from sell and raised its price target. Analysts gave little credence to a rumor that Australian rival BHP Billiton Ltd (BHP.AX) may be seeking to acquire Alcoa.

And on Nasdaq, shares of Autodesk (ADSK.O) shot up 10.4 percent to $16.81 after UBS upgraded the design software and services company's stock.

On the economic front, the picture remained bleak but investors appeared to pay less attention to the data, with damage limited to the homebuilding sector.

In addition to January's record drop in home prices, March U.S. consumer confidence came in barely above the record monthly low.

The Institute for Supply Management-Chicago index of business activity fell in March at a rate that was more severe than expected.

The Dow Jones homebuilders index(.DJUSHB) fell 3.2 percent.

Trading was active on the New York Stock Exchange, with about 1.64 billion shares changing hands, above last year's estimated daily average of 1.49 billion, while on Nasdaq, about 2.20 billion shares traded, below last year's daily average of 2.28 billion.

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