Bank of America Corp. has agreed to fork over nearly $17 billion to settle government claims over toxic mortgage securities that helped trigger the Great Recession, according to people close to the negotiations with the Justice Department.

The agreement -- $9 billion in cash penalties and the rest in mortgage modifications and other consumer relief -- remained tentative on Wednesday, these people said. It would be by far the largest in a series of billion-dollar settlements with the "too big to fail" banks over the subprime mortgage meltdown.

At issue are $245 billion in soured home loans, only $10 billion of which were from Bank of America. The rest were sold, packaged in bonds, by three firms BofA acquired in 2008 -- the giant Calabasas high-risk lender Countrywide Financial Corp., Wall Street fixture Merrill Lynch & Co., and First Franklin Financial Corp., a big San Jose subprime specialist that Merrill had purchased in 2006.

Bank of America had resisted government demands that it pay $17 billion to settle its liabilities. It argued that the penalty was too severe for bad investments sold by others, although it eventually raised its settlement offer to $13 billion and then $14 billion.

Then, after a trial the bank lost, a New York judge last week ordered it to pay $1.3 billion for mortgages sold in a 2007 Countrywide program called the Hustle. At that point, Bank of America chief Executive Brian Moynihan threw in the towel and got in touch with U.S. Atty. Gen. Eric Holder.

"It removed the theoretical element of what happens if you fight this kind of thing," said one person familiar with the negotiations.

Three people briefed on negotiations between the bank and the U.S. Justice Department said Wednesday that details were still being negotiated on exactly what admissions Bank of America would make and how more than $7 billion in consumer relief would be allocated.

The people spoke about the confidential talks on condition their names not be disclosed.

"This thing could still fall apart," one source said, adding that it was unlikely the deal would be finalized before next week.

The pending agreement follows a series of similar deals with major Wall Street firms investigated by a task force of federal and state officials focused on mortgage-backed securities sold in the years running up to the financial crisis.