The largest civil settlement in U.S. history, a US$16.65 billion deal with Bank of America (BofA), was announced Thursday, settling allegations connected with the packaging and sale of mortgage securities in the run up to the financial crisis.

The U.S. banking giant has reached a comprehensive settlement with the U.S. Department of Justice (DoJ), federal agencies (including the U.S. Securities and Exchange Commission and the FDIC), and six states (California, Delaware, Illinois, Kentucky, Maryland and New York), that will see the bank pay US$9.65 billion in cash and provide US$7.0 billion in consumer relief. The cash portion consists of a US$5.02 billion civil monetary penalty and US$4.63 billion remediation payments. The consumer relief will take the form of mortgage modifications, which the bank has pledged to deliver by August 31, 2018; and will be subject to oversight by an independent monitor.

The claims relate primarily to conduct that occurred at financial firms that were acquired by BofA during the financial crisis, Countrywide and Merrill Lynch. The settlement resolves claims involving the securitization, origination, sale and other conduct relating to residential mortgage-backed securities (RMBS) and collateralized debt obligations (CDOs), among other things. The settlement does not cover potential criminal claims; potential claims against individuals; and certain purported whistleblower actions.

“This historic resolution – the largest such settlement on record – goes far beyond ‘the cost of doing business,'” said U.S. attorney general, Eric Holder. “Under the terms of this settlement, the bank has agreed to pay US$7 billion in relief to struggling homeowners, borrowers and communities affected by the bank’s conduct. This is appropriate given the size and scope of the wrongdoing at issue.”

The bank says that settlement will reduce its third quarter pre-tax earnings by US$5.3 billion. “We believe this settlement, which resolves significant remaining mortgage-related exposures, is in the best interests of our shareholders, and allows us to continue to focus on the future,” said BofA’s CEO, Brian Moynihan.

The multi-billion dollar settlement is largely neutral to the bank’s credit ratings, says Fitch Ratings.

The rating agency says that the deal will likely cause the bank to post a net loss in in the third quarter, but that its capital ratios should remain relatively flat. This latest settlement, combined with its other settlements, litigation costs, and charges over the last few years pushes its legal costs to, what Fitch says is the “higher end” of its internal estimates of total mortgage and legal related exposure. It estimates that total costs and losses related to litigation is “likely north of US$60 billion”.

If other unforeseen, or large settlements or litigation costs arise, which absorb earnings or constrain capital accumulation, Fitch says there could be negative pressure on the company’s ratings.

Conversely, it says that the deal could have positive rating implications if it largely resolves the bank’s legacy exposures and ongoing litigation, “and allows management to focus more of its efforts on running and improving Bank of America’s core businesses.”