The Dow Jones industrial average closed up 204 points at 12,777. It was the first gain in the market all week. The Standard & Poor's 500 index ended at 1,357, up 22, and the Nasdaq composite rose 42 to finish at 2,908.
JPMorgan shares increased 5.8 percent, by far the biggest gain of the 30 stocks in the Dow, and closed at $36.02.
JPMorgan, the country's biggest bank, earned $5 billion in the most recent quarter, easily beating Wall Street's forecasts. That came as a relief to investors who had been worrying about weaker earnings at major U.S. companies.
Investors were also relieved that JPMorgan's trading loss wasn't as bad as the most dire predictions. JPMorgan revealed that the loss from a derivative trade it first disclosed in May had grown to $5.8 billion, nearly triple the original estimate. The bank's stock shot up $2 to $36.05.
JPMorgan's underwriting business also fared better than many expected. Those results rubbed off on the investment banks Goldman Sachs and Morgan Stanley, driving both up more than 3 percent. Goldman jumped $3.45 to $97.47. Morgan Stanley rose 46 cents to $14.01.
Wells Fargo, the other major bank reporting results Friday, said a rise in lending drove its net income up 18 percent. Wells Fargo has managed to avoid problems plaguing other big banks and is now the country's largest mortgage lender. Its stock rose 3 percent, to $33.86. Citibank (C) and Bank of America (BAC) also posted big gains
Todd Salamone, director of research at Schaeffer's Investment Research, said the rally in bank stocks shows that investors had been preparing for the worst. When they're too gloomy on an industry, the slightest bit of good news can jolt their stocks up.
"The bar for earnings is set extremely low, and a lot of people have been betting against banks" he said. "The lower the bar, the easier it is for positive surprises."
Even with the surge Friday, major market indexes are still on their way to weekly losses. The Dow is down 0.2 for the week, and the S&P 500 is off by 0.1 percent. The technology-heavy Nasdaq, which is more sensitive to swings in the economy, has slumped 1.2 percent.
The stock market took a beating this week as the U.S. corporate earnings season got off to a weak start and Europe stumbled along in its latest attempts to resolve the region's debt crisis.