Stocks sold off late in the session to end with modest gains on Tuesday as Citigroup's steep drop in profit gave investors a reason to unload bank shares.

The Dow Jones industrial average <.DJI> was up 60.01 points, or 0.48 percent, to end unofficially at 12,482.07. The Standard & Poor's 500 Index <.SPX> was up 4.58 points, or 0.36 percent, to finish unofficially at 1,293.67. The Nasdaq Composite Index <.IXIC> was up 17.41 points, or 0.64 percent, to close unofficially at 2,728.08.

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.

(Reporting By Angela Moon; Editing by Jan Paschal)