Deutsche Bank and Credit Suisse Group have agreed to pay a combined $12.5 billion to resolve U.S. investigations into sales of the toxic debt that fueled the financial crisis, putting behind them a major dispute that undermined confidence in the banks and raised questions about their turnarounds.

Deutsche Bank will pay $7.2 billion and take a $1.2 billion pretax charge this quarter, while Credit Suisse agreed to a $5.3 billion deal and will recognize a $2 billion hit to earnings, the banks said in separate statements early Friday. Their announcements came hours after Barclays Plc, which is being probed in a related case, was sued for fraud Thursday by the Justice Department after it balked at paying the amount the government sought in negotiations.

Before the deals announced on Friday, authorities had already extracted more than $46 billion from six U.S. financial institutions over their dealings in mortgage-backed securities.

The Justice Department declined to comment.

Deutsche Bank will pay a $3.1 billion civil penalty and provide $4.1 billion in relief to consumers. The bank had set aside $6.2 billion for outstanding legal costs as of Sept. 30.

The deal is far below the Justice Department's initial request of $14 billion, which had spooked stock and bond holders this year. Bank of America Corp., which had the largest such settlement, agreed to pay $16.7 billion over bonds that were worth four times those of Deutsche Bank.

Germany's biggest bank still faces probes into whether it manipulated foreign-currency rates and precious metals prices, and whether it facilitated transactions that helped investors illegally transfer billions of dollars out of Russia. The bank said an internal review by the bank found "deficiencies" in the bank's systems and controls in Russia, but no indications that it breached sanctions in the country.

Credit Suisse will pay a $2.48 billion civil penalty and $2.8 billion in relief, to be paid over five years following the settlement. Credit Suisse had set aside about $2.1 billion in general litigation provisions by the end of the third quarter.

The Swiss bank remains under Justice Department scrutiny over its handling of U.S. clients in Israel. The department fined Credit Suisse $2.6 billion in 2014 for helping Americans dodge taxes in Switzerland. The bank is also a target of several antitrust cases in the United States, including class actions related to foreign-exchange rates and interest-rate swaps.

Unlike Credit Suisse and Deutsche Bank, Barclays was unable to reach an agreement, marking the first time the Justice Department has sued one of the banks at the center of an Obama administration initiative to recoup investor losses on mortgage securities. The lawsuit is rare for big banks, which typically settle with the government rather than risk drawn-out litigation and a possible trial.

The breakdown in talks suggests that the bank is willing to take its chances with incoming enforcement officials in the Trump administration. The bank has lined up a law firm whose top lawyer is known for his aggressive defense of clients.

At least three other European banks remain under investigation over the role of their mortgage-backed securities business: UBS Group AG, HSBC Holdings Plc, and Royal Bank of Scotland Group Plc.