CORRECTION, 10/14/13, 10:45 a.m. EDT: A previous version of this story incorrectly reported the dollar value of a settlement between Citigroup Inc. and the Federal Housing Finance Agency. The amount was undisclosed. The eighth paragraph has been revised with the correct information. We regret the error.

With legal battles forcing JPMorgan Chase & Co. to set aside an eye-popping $23 billion for litigation costs, several Am Law 100 firms are reaping hefty legal fees for their work representing the bank, including Sullivan & Cromwell, Wilmer Cutler Pickering Hale and Dorr, and Paul Weiss Rifkind Wharton & Garrison.

In its earnings release on Friday, JPMorgan revealed a third-quarter loss of $380 million, due in large part to a $9.2 billion pretax charge to cover legal expenses. In an unusually transparent move, the bank revealed that it now has $23 billion reserved to cover litigation costs. By way of comparison, its legal reserve in 2010 was $3 billion.

“We continuously evaluate our legal reserves, but in this highly charged and unpredictable environment, with escalating demands and penalties from multiple government agencies, we thought it was best to significantly strengthen them,” JPMorgan CEO James Dimon said in a statement.

Among the bank’s staggering legal costs is the $920 million it paid to U.S. and U.K. regulators in September to resolve probes into its handling of the “London Whale,” a trader who accumulated $6 billion in losses by making outsize bets in debt markets. Wilmer partners Harry Weiss and Howard Shapiro represented JPMorgan in that case. The settlement included a rare admission of wrongdoing, as we reported here.

JPMorgan’s relationship with Wilmer can be traced back to the bank’s general counsel Stephen Cutler, who joined JPMorgan in 2006 from Wilmer’s Washington, D.C., office, where he was cochair of the firm’s securities department in 2005. He had previously served as a partner at Wilmer for 11 years before heading to the Securities and Exchange Commission in 1999, where he later served as director of the agency’s division of enforcement from 2001 to 2005.

JPMorgan is also racking up expenses as its mortgage practices are being probed by U.S. attorney’s offices in California, New Jersey, and Pennsylvania. The civil division of the U.S. Attorney’s Office in Sacramento informed JPMorgan in May that it had “preliminarily concluded” that the bank misled investors about mortgage-backed securities between 2005 and 2007. JPMorgan is hoping to settle the case before a complaint is filed, according to a lawyer familiar with the case who asked not be identified because the proceedings are confidential. JPMorgan is also trying to structure a settlement that minimizes its liability in a parallel investor class action, according to the lawyer.

Meanwhile, Sullivan & Cromwell partners Sharon Nelles and Penny Shane are defending JPMorgan against claims filed by the Federal Housing Finance Agency, the conservator to Fannie Mae and Freddie Mac. As part of a massive litigation offensive against big banks, the FHFA sued JPMorgan in July 2011 in U.S. district court in Manhattan. The agency alleges that JPMorgan duped Fannie and Freddie into buying a combined $33 billion in mortgage-backed securities. The case is scheduled for trial in June 2014 before Judge Denise Cote, who has sided with FHFA and its lawyers at Quinn Emanuel Urquhart & Sullivan on several crucial pretrial issues.

Citigroup Inc. settled a similar FHFA lawsuit for an undisclosed sum in May. The agency sued Citi over just $3.5 billion in MBS, so JPMorgan’s potential liability is much larger. In August, Bloomberg BusinessWeek reported the FHFA had proposed a $6 billion settlement with JPMorgan.

JPMorgan CEO Dimon has demonstrated an eagerness to put the cases behind him. On September 24, he met with Attorney General Eric Holder to discuss a potential settlement. For the meeting, Dimon brought with him Cutler, as well as Sullivan & Cromwell senior chairman H. Rodgin Cohen. The Wall Street Journal reported that Holder proposed a settlement of at least $11 billion, which could cover both the Justice Department cases and the FHFA litigation.

Sullivan & Cromwell enjoys a long relationship with JPMorgan. In 2008 the firm advised the bank on its $1.9 billion acquisition of Washington Mutual Inc. Around the same time, Cohen advised Bear Stearns on its sale to JPMorgan. In November 2012, JPMorgan hired former Sullivan & Cromwell partner Stacy Friedman to helm its recently formed corporate and investment bank division.

JPMorgan has also turned to Paul Weiss Rifkind Wharton & Garrison for some of its recent legal troubles. In August, the bank retained Paul Weiss to handle an SEC investigation into a probe of the bank’s hiring practices in Hong Kong. The SEC is seeking to determine whether the bank hired the children of top-ranking Chinese government officials in hopes of getting lucrative contracts. Last month, Paul Weiss chairman Brad Karp told The New York Times that there is “no better general counsel on Wall Street” than Cutler. Judging from Friday’s announcement, he’s certainly the one with the most on his plate.

Senior reporter Jenna Greene of sister publication The National Law Journal contributed to this article.