Stocks on Wall Street advanced 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 stock indexes up about 1 percent.

The Dow Jones industrial average closed up 0.5 percent, while the Standard & Poor’s 500-stock index was up 0.4 percent. The Nasdaq composite index was up 0.6 percent.

Across the Atlantic, the Euro Stoxx 50, an index of euro zone blue chips, rose 1.5 percent. The FTSE 100 in London added 0.7 percent.

The financial sector took a hit from investors’ disappointment with Citigroup’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.

“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 adviser and portfolio manager at Cozad Asset Management in Champaign, Ill.

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,” Mr. Evans said.

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

Also Tuesday, Wells Fargo 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 in late trading.

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