Stocks advanced on Tuesday but sharply pared gains late in the session after Citigroup's steep drop in profit gave investors a reason to unload bank shares.

The late-day selloff reflected a reversal in prevailing sentiment, when earlier optimism about the economy and China's growth prospects had driven the major U.S. stock indexes up about 1 percent.

The financial sector took a hit from investors' disappointment with Citigroup Inc's earnings. Citigroup's stock slid 8 percent to a session low at $28.29 after it reported weaker-than-expected earnings.The KBW Banks Index lost 1.6 percent.

Citigroup's results followed similarly disappointing earnings on Friday from JPMorgan Chase & Co .

It was expected that some of the big banks would continue struggling, especially those heavily involved in investment banking because that part of the financial system has clearly slowed down, said Bryant Evans, investment advisor and portfolio manager at Cozad Asset Management, in Champaign, Illinois.

The Dow Jones industrial average <.DJI> was up 64.78 points, or 0.52 percent, at 12,486.84. The Standard & Poor's 500 Index <.SPX> was up 3.83 points, or 0.30 percent, at 1,292.92. The Nasdaq Composite Index <.IXIC> was up 13.91 points, or 0.51 percent, at 2,724.58.

Earlier in the day, stocks rallied about 1 percent across the board after data showed China's economy expanded at the weakest pace in 2-1/2 years, suggesting officials may try to boost growth in the near term by tweaking monetary policy.

The news followed late Friday's widely expected announcement by Standard & Poor's that it was downgrading the credit ratings of nine euro-zone countries.

The overall sense is that perhaps the rest of the world can continue on a growth path despite what's going on in Europe, Evans said.

I think what we have here is a soft landing in China, he added.

Leading the Dow's advance was heavy equipment maker Caterpillar , up 1.2 percent at $103.72.

Citigroup's results followed similarly disappointing earnings on Friday from JPMorgan Chase & Co .

At the same time, Wells Fargo & Co posted a 20 percent jump in quarterly profit. Wells Fargo's stock, which earlier had risen more than 1 percent to a session high at $30.69, pulled back sharply from that high and was up just 0.4 percent at $29.72 in late afternoon trading.

The benchmark S&P 500 briefly moved above 1,300 on an intraday basis for the first time since August 1. Analysts said a substantial move past that resistance point could trigger more buying.

On the U.S. economic front, a gauge of manufacturing in New York State rose to its highest level in nine months, keeping in line with the trend of modest improvement in U.S. economic data.

(Reporting By Caroline Valetkevitch, Additional reporting by Ryan Vlastelica; Editing by Jan Paschal)