JPMorgan Chase has tentatively agreed to pay the Department of Justice a record $13 billion settlement to resolve several civil probes relating to residential mortgage-backed securities — a costly deal that still doesn’t protect the bank against additional criminal prosecutions.

The settlement, revealed Saturday, would be the largest lump payout the US government has ever asked of an individual company.

“This is a basic and fundamental attack on capitalism,” declared Dick Bove, an influential bank analyst at Rafferty Capital.

“It is possible that the government is taking away the property of the JPMorgan shareholders without the shareholders having committed any crime or having any say in the expropriation of these funds.”

The deal includes an undisclosed sum to settle a civil suit brought by NY state attorney general Eric Schneiderman.

Under the settlement, JPMorgan must continue to cooperate with federal investigators probing the banking giant’s issuance of mortgage-backed securities from 2005 to 2007, according to sources.

Still to be ironed out are how to resolve that criminal investigation, along with the wording of any admissions of culpability the feds might require.

The general terms of the settlement deal were forged Friday in a phone conversation between Attorney General Eric Holder and JPMorgan CEO Jamie Dimon, The Wall Street Journal reported.

Analysts called the settlement a raw deal given that, by JPMorgan’s own estimate, some 80 percent of its mortgage-backed securities had been acquired at the request of the government, when it bought Bear Stearns and Washington Mutual in 2008.

“I just think that these banks like JPMorgan are being whacked like a pinata,” said Doug Kass, a hedge-fund manager at Seabreeze Partners.

“This sounds like a raw deal for JPMorgan and shareholders,” Kass said.

“Ultimately, the earnings power of banks is being regulated out of them from the [Securities and Exchange Commission], from the Department of Justice,” Kass added.

The settlement sum includes $4 billion that JPMorgan agreed this month to pay the Federal Housing Finance Agency to resolve allegations that the bank misled mortgage-finance companies Fannie Mae and Freddie Mac about the quality of loans it sold them prior to the 2008 financial crisis, the Journal reported.

The bank said this month that it has set aside $23 billion for its legal expenses and settlement costs this year alone.