JPMorgan Chase and the Department of Justice have tentatively agreed to a $13 billion civil settlement to resolve several investigations into the bank's mortgage securities business, according to a U.S. official familiar with the negotiations.

Mortgage-backed securities and related derivatives were a key cause of the financial crisis, saddling financial institutions with losses as the housing market cratered. If completed, the settlement would be substantially larger than any law enforcement officials have secured from a single institution in connection with the crisis.

The settlement includes $9 billion in fines and penalties and $4 billion in 'consumer relief,' including home loan modifications, the official said.

A federal criminal investigation based in Sacramento continues, and the deal does not include a non-prosecution agreement that JPMorgan Chase (JPM) had originally insisted be part of the deal, the official said.

As the criminal case develops, JPMorgan Chase has agreed to assist in an investigation that is pursuing possible charges against individuals, the official told CNN.

JP Morgan Chase declined to comment to CNN.

The tentative deal includes a $4 billion settlement regarding allegations by the Federal Housing Finance Agency that JP Morgan Chase misled Fannie Mae and Freddie Mac when it sold them home loans, many of which soured.

Related: JPMorgan fined $920 million in 'London Whale' trading loss

Fannie and Freddie sustained massive losses on mortgage-backed securities as the housing market imploded, and required a bailout of over $187 billion. The firms, which have been overseen by the FHFA since their 2008 rescue, have since returned to profitability, paying $136 billion in dividends to the Treasury Department.

The settlement also would resolve a smaller separate case brought by New York Attorney General Eric Schneiderman. Schneiderman sued JP Morgan Chase in October over alleged deceptive practices in sales of mortgage bonds by Bear Stearns, which was acquired by JP Morgan Chase.

The $13 billion deal is $2 billion higher than the most recent offer by JPM, and came at the end of talks that included personal negotiations between Attorney General Eric Holder and JPM Chief Jamie Dimon, CNN is told.

Related: JPMorgan's Dimon meets Holder for settlement talks

Dimon visited the Justice Dept in late September for a meeting in Holder's conference room, the official said, and last week the two men spoke by phone to discuss the final sticking point: Dimon's insistence that the deal include a non-prosecution agreement.

Holder told Dimon it was a "non-starter" according to the official. In a call Friday at around 6pm, Holder and Dimon made the final deal after Dimon dropped the non-prosecution condition.

The $13 billion civil settlement covers conduct from 2005-2007 and includes investigations of the mortgage businesses of Washington Mutual and Bear Stearns, which were both acquired by JPM.

Related: 5 years after Lehman: Where are key players now?

Lawyers for both sides, led by Tony West, associate attorney general, and Stephen Cutler, JPM's general counsel, are expected to work through the weekend to finalize details of the agreement, which will be announced in the coming days.

The settlement is the latest in a series of legal headaches for JPMorgan, America's largest bank by assets.

The firm has paid over $1 billion in fines in connection with last year's "London Whale" trading debacle, and $80 million more over allegedly unfair credit card billing practices.

In July, the bank agreed to pay $410 million to settle charges that it manipulated electricity prices in California and the Midwest. It is also facing scrutiny over its hiring practices in China and its alleged involvement in the Libor rate-fixing scandal.

Related: JPMorgan posts loss on big legal costs, but ...

JPMorgan posted a loss for the third quarter based on its massive legal expenses. Dimon called the loss "painful" and warned that litigation costs could continue to be a drag on earnings for several quarters.

The bank said at the time that it was holding $23 billion in reserves for potential litigation expenses, but that its legal costs could be nearly $6 billion above that figure in a worst-case scenario.

One point of contention during settlement negotiations has been whether JPMorgan ought to be responsible for misconduct at Bear Stearns and WaMu that occurred before it absorbed them.

Commenting last year on litigation related to Bear, Dimon argued that the firm had been acquired during the turmoil of 2008 as "a favor" to the Federal Reserve.

Related: J.P. Morgan's current woes may be the least of its problems

Analysts at Oppenheimer argued in a recent research note that JPMorgan was being targeted unfairly and out of proportion with its role in the crisis.

"[O]ne reason why JPM was strong enough to absorb Bear and WAMU is precisely because its involvement in the mortgage mess was relatively small," the analysts wrote. "JPM's exposure got large because it helped the government by taking Bear and WAMU."

Others are less sympathetic, noting JPMorgan's initial enthusiasm over these deals and the revenues they've generated since.