U.S. stocks logged their best one-day gain in about six weeks on Wednesday after a bullish forecast from financial company State Street Corp fueled optimism about the coming earnings season and helped the S&P 500 break above a major resistance level.

State Street shares closed 9.9 percent higher at $36.63 after the asset manager and custody firm said quarterly earnings would far exceed expectations, providing a lifeline to investors after several weeks of dismal economic reports.

Bank stocks led the way, but investors also scooped up beaten-down industrial and technology shares.

There is some confidence now that there will be more positive surprises than negative during the earnings season, said Marc Pado, U.S. market strategist at Cantor Fitzgerald & Co in San Francisco.

The Dow Jones industrial average <.DJI> rose 274.66 points, or 2.82 percent, to 10,018.28. The Standard & Poor's 500 Index <.SPX> gained 32.21 points, or 3.13 percent, to 1,060.27. The Nasdaq Composite Index <.IXIC> advanced 65.59 points, or 3.13 percent, to 2,159.47.

It was the indexes' biggest percentage advance since May 27.

The KBW bank index <.BKX> climbed 5.6 percent, while State Street rivals Northern Trust Corp rose 6.9 percent to $49.14 and Bank of New York Mellon Corp was up 6.4 percent to $26.32.

European banks also rallied on optimism most would pass the European banking stress tests, giving a boost to the wider market.

When the benchmark S&P 500 index broke through 1,040, it fueled more buying by those who had put on short positions. The 1,040 level was viewed as a resistance level to further gains, according to Todd Salamone, vice president of research at Schaeffer's Investment Research.

That creates a very crowded position that is very vulnerable to an unwind, and I think we're seeing that today, he said.

The S&P 500 closed around 1,060, the next resistance level that could prevent the index from rising further on Thursday. The index has reached the 23.6 percent retracement of the move from its 2010 high in April to its year low hit last week.

Industrial and technology stocks were also among the day's gainers with General Electric up 4.7 percent at $14.62

and Cisco System up 5.3 percent at $22.48. The two stocks were the top gainers on the Dow.

Energy shares also got a boost from August crude futures that advanced 3.4 percent to $74.43 a barrel, sending the S&P energy index <.GSPE> up 3.2 percent.

Crude climbed on the expectation that upcoming data would show a drop in U.S. inventories, a positive sign for demand, as well as weakness in the U.S. dollar.

But analysts warned that the rally may be short-lived, considering the current economic conditions.

We may see riskier behavior heading into the next couple of days. It's not uncommon to see a short term technical rally, said Tom Schrader, managing director at Stifel Nicolaus Capital Markets in Baltimore.

(But) I don't think it's sustainable beyond about a week. The overall economic situation is not conducive to equities.

UBS lowered its full-year forecast on the S&P to 1,150 from 1,350. The firm said the reduced view reflected modestly weaker earnings growth and longer-term secular headwinds.

In earnings news, Family Dollar Stores Inc tumbled 8 percent to $36.26 after it forecast fourth-quarter earnings below expectations.

Among its discount retailer peers, Dollar Tree Inc slipped 3.1 percent to $41.61 while BJ's Wholesale Corp was off 1.1 percent at $42.72.

BP Plc Chief Executive Tony Hayward met with officials from Abu Dhabi's investment authority as speculation mounted the sovereign fund would make a fresh investment. BP's U.S.-listed shares rose 4 percent to $33.12.

Overall volume was tepid, with about 8.95 billion shares traded on the New York Stock Exchange, the American Stock Exchange and Nasdaq, below last year's estimated daily average of 9.65 billion.

Advancing stocks outnumbered declining ones on the NYSE by 2650 to 431, while on the Nasdaq, advancers beat decliners by 2080 to 588.

(Additional Reporting by Rodrigo Campos and Matt Lynley; Editing by Kenneth Barry)