America's biggest bank, JP Morgan, made a loss in the third quarter of 2013 after legal expenses of $9.2bn (£5.8bn) caused by a wave of regulatory investigations and potential lawsuits.

The bank, thought until recently to have weathered the financial crisis well, has put aside $23bn for potential litigation since 2010 and admitted yesterday its legal bills could be $6.8bn more.

Jamie Dimon, the bank's chairman and chief executive, described the loss – his first since taking charge in December 2005 and the first since 2004 – as painful.

The third-quarter loss is a dramatic reversal for a bank that has survived the five years since the financial crisis without falling into the red and even reported record profits for the last three years. During the crisis, JP Morgan was regarded as strong enough to rescue fallen banks Bear Stearns and Washington Mutual.

Dimon, who ignored calls to split his management roles earlier this year, said: "We are just trying to improve and move on. Remember these things are related to multiple year events. Remember we didn't lose any money during the crisis." But five years on from the crisis, the bank has been hit by more than $900m in fines for the London Whale trading incident and is locked in talks about the penalties it will incur for the sale of sub-prime mortgage-backed securities in the runup to the 2007 credit crunch. The settlement could cost a record $11bn.

As a result of those discussions –in which Dimon has been personally involved – the bank took a $7.2bn legal charge, or $9.2bn before tax, which caused a $400m loss for the quarter compared with a profit of $5.7bn the same time last year. Dimon would rather have focused on the bank's earnings before the one-off legal provisions – $5.8bn – after its revenue fell to $24bn, from $26bn in the same period last year.

Last month, Dimon went to Washington to meet the attorney general, Eric Holder, in an attempt to reach an agreement that could include $4bn of payments to consumers and $7bn of penalties over sub-prime mortgage losses. But Dimon said on Friday that reaching a deal involved "multiple agencies so you can imagine how complicated it is." The firm is facing more than a dozen investigations, including one about hiring the children of executives of Chinese state-owned companies.

Dimon said an otherwise strong performance had been "marred by large legal expense". Marianne Lake, JP Morgan's chief financial officer, cautioned that the legal expenses were "significantly larger than we could have anticipated even a short while ago".

"We would love to reduce the uncertainty around this but it is really hard to do and it will probably be lumpy," Dimon told analysts. "There are multiple agencies involved in every case now, we just have to deal with it and it will abate over time. One day it won't be a big number. Our preference is to resolve it and it is very hard to work with government and regulators. We want to do the right thing for our shareholders and hopefully over time we will make this a much smaller issue."

Dimon made reference to the two firms JP Morgan rescued during the crisis – Bear Stearns and Washington Mutual – which were involved in the mortgage scandal. "The board continues to seek a fair and reasonable settlement with the government on mortgage-related issues – and one that recognises the extraordinary circumstances of the Bear Stearns and Washington Mutual transactions, which were undertaken at the request or encouragement of the US government," Dimon said.

The settlement talks are taking place just after the bank has been fined $920m by regulators in the US and the UK for the London Whale trading incident last year, which cost the bank $6.2bn in losses and led to Dimon's bonus being cut in half.