JPMorgan Chase & Co. (NYSE:JPM), the largest U.S. bank by assets, on Friday reported a $380 million loss, or 17 cents per share, in the third quarter on lower revenue and massive legal bills. That compares with net income of $5.7 billion, or $1.40 per share, a year earlier.

Excluding litigation expense, the New York financial giant posted a profit of $5.82 billion, or $1.42 per share. Analysts on average had forecast a profit of $1.17 per share before items, according to a Thomson Reuters poll. It wasn't immediately clear if the results were comparable.

Revenue fell 8 percent, to $23.9 billion, roughly in line with Wall Street's expectations, the poll said.

JPMorgan took a $7.2 billion charge to cover legal bills, which CEO Jamie Dimon -- who is facing his first loss at the bank since he took the top spot in 2004 -- said had climbed to nearly $9.2 billion, or $7.2 billion after taxes.

Despite the setback, shares climbed because the bank's core earnings beat analyst estimates. The quarter was marked by increased loans, robust equity-trading revenue and improved credit quality. Shares also climbed because JPMorgan disclosed for the first time that it has set aside $23 billion as it addresses an array of government lawsuits. 

“In this highly charged and unpredictable environment, with escalating demands and penalties from multiple government agencies, we thought it was prudent to significantly strengthen” the bank’s legal reserves, Dimon said. “While we expect our litigation costs should abate and normalize over time, they may continue to be volatile over the next several quarters.”