JPMorgan has agreed a provisional deal with the US government to pay $13bn to settle investigations into bad mortgage loans the bank sold to investors before the financial crisis.

Under the agreement, the bank will pay $9bn in fines to the US government and $4bn for relief for struggling homeowners, sources told the AP news agency on Saturday.

The tentative deal does not release the bank from criminal liability, a factor that had been a major sticking point in the discussions, the source said.

If the agreement is finalised it would be the US government's highest-profile enforcement action related to the financial meltdown that plunged the economy into the deepest recession since the 1930s.

As part of the deal, the Justice Department expects JPMorgan to co-operate with the continuing criminal probe of the bank's issuance of mortgage-backed securities between 2005 and 2007, the person said.

When the housing bubble burst in 2007, bundles of mortgages sold as securities soured and the investors who bought them lost billions.

In the aftermath, public outrage boiled over that no high-level Wall Street executives had been sent to jail. Some politicians and other critics demanded that the big bailed-out banks and senior executives be held accountable.

In response, the government in January 2012 set up a task force of federal and state law enforcement officials to pursue wrongdoing with regard to mortgage securities.

Earlier this month JPMorgan disclosed it had stockpiled $23bn in reserves for settlements and other legal expenses to help cover the myriad investigations into its conduct before and after the financial crisis.