U.S. stocks gained on Tuesday as brighter sentiment about China's growth prospects overshadowed Europe's recent credit downgrades and a mixed bag of big bank earnings.

China's economy expanded at the weakest pace in 2-1/2 years, data showed, suggesting officials may try to boost growth in the near term by tweaking monetary policy.

Bank earnings offered a mixed picture, with Wells Fargo & Co posting a 20 percent jump in quarterly profit, while Citigroup Inc's earnings were weaker than expected. Wells Fargo rose 1.3 percent to $29.99, while Citigroup lost 6.9 percent to $28.63.

The KBW Bank index <.BKX>, which had risen nearly 11 percent for the year, slipped 0.5 percent.

Investors looked beyond Standard & Poor's credit downgrade of the euro zone's rescue fund, relieved it was not more severe. The move came after Friday's widely expected downgrade of the credit ratings of nine euro-zone countries.

The bad news is really good news in China, since if they are slowing more than expected, then there's an expectation for further stimulus, said Matt King, chief investment officer at Bell Investment Advisors in Oakland, California. We're seeing a clear shift from risk aversion with the lack of reaction to Europe, and the market has likely seen a bottom.

The Dow Jones industrial average <.DJI> was up 98.88 points, or 0.80 percent, at 12,520.94. The Standard & Poor's 500 Index <.SPX> was up 8.94 points, or 0.69 percent, at 1,298.01. The Nasdaq Composite Index <.IXIC> was up 26.27 points, or 0.97 percent, at 2,736.94

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

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.

Information technology shares were the day's biggest gainers, led by Applied Materials Inc . RBC upgraded the stock to outperform, and it rose 2.7 percent to $11.81.

Among companies in the news, shares of Carnival Corp lost 14.1 percent to $29.44 as its Italian unit, Costa Crociere, struggled to locate missing passengers after a cruise liner capsized. Fellow cruise operator Royal Caribbean Cruises Ltd slid 4.7 percent to $27.41.

KU6 Media Co Ltd shares more than doubled, surging more than 100 percent to a session high of $4.04 after it signed a deal to offer its videos on Google Inc's YouTube website. The stock was later up nearly 116 percent at $2.98.

As of early afternoon, advancers outnumbered decliners on the New York Stock Exchange by a ratio of about 7 to 3, while on the Nasdaq, about five stocks rose for every three that fell.

(Reporting By Ryan Vlastelica; Editing by Jan Paschal)