U.S. investment bank JPMorgan has put the finishing touches on a settlement that would see the bank pay $13 billion to make numerous government complaints into their subprime mortgage business go away.

Details of the agreement between the investment bank and the U.S. Justice Department were released on Tuesday afternoon at about 2:30 ET.

At $13 billion, it is the largest settlement between the U.S. government and a corporation in American history. The previous was record was $4 billion, which was what BP agreed to pay in January to settle the gulf oil spill.

The $13-billion figure is also more than half of the $21 billion that the bank earned in profits last year. Last quarter, the bank posted a rare quarterly loss — of $9 billion — under the stewardship of CEO Jamie Dimon, because of the uncertainty related to the settlement.

Despite the eye-popping figure, investors seemed to welcome the news for bringing closure to the issue, as JPM shares gained more than one per cent to $56.50 on the NYSE.

The fine ends years of negotiations to find a suitable reimbursement for the amount investors, homeowners and taxpayers who suffered in the years following the recession, when JPMorgan and other banks sold billions of low-quality mortgages to unqualified buyers, which collapsed the housing market.

Dimon contends most of the troubled loans weren't originated at the bank and were instead inherited when JPMorgan acquired Bear Stearns Cos. and Washington Mutual Inc. in 2008.

Homeowner relief

Deputy Attorney General James Cole told the American Bankers Association that too many supervisors incentivized excessive risk taking, knowing that risky products "could be unloaded down the road … leaving someone else to deal with the consequences."

Roughly $6 billion of the settlement would go to investors, while $4 billion would go directly to homeowners, by reducing principals, lowering rates and originating new loans. Some of that $4 billion would be earmarked to helping foreclosed homeowners in distressed property areas such as Detroit, AP says. The remainder will be a fine, kept by the government.

New York Attorney General Eric Schneiderman, who sued JPMorgan in 2012, says the state will get $613 million in cash and about $400 million in relief for struggling homeowners.

The settlement would also end any civil financial penalties, but would not prevent the U.S. government from going ahead with criminal charges.