WASHINGTON (AP) — Bank of America is nearing a $16 billion to $17 billion settlement to resolve an investigation into its role in the sale of mortgage-backed securities before the 2008 financial crisis, a person directly familiar with the matter said Wednesday.

The deal with the bank, which must still be finalized, would be the largest Justice Department settlement by far arising from the economic meltdown in which millions of Americans lost their homes to foreclosure. It would follow earlier multibillion-dollar agreements reached in the last year with Citigroup and JPMorgan Chase & Co.

The person, who spoke on condition of anonymity because the deal had not yet been announced, cautioned that some details still needed to be worked out and that it was possible the agreement could fall apart.

But the person said the two sides reached an agreement in principle following a conversation last week between Attorney General Eric Holder and Bank of America CEO Brian Moynihan.

The person said the tentative deal calls for the bank to pay roughly $9 billion in cash and for the remaining sum to go toward consumer relief.

A bank spokesman declined to comment.

The Wall Street Journal first reported details of the settlement discussions on Wednesday.

The deal would be the latest arising from the sale of toxic mortgage securities leading up to the recession. The Justice Department last year reached a $13 billion settlement with JPMorgan and in July announced a $7 billion settlement with Citigroup.

Each of these deals is designed to offer some financial relief to homeowners, whose mortgages were bundled into securities by the banks in question and then sold to investors. The securities contained residential mortgages from borrowers who were unlikely to be able to repay their loans, yet were publicly promoted as relatively safe investments until the housing market collapsed and investors suffered billions of dollars in losses.

The poor quality of the loans led to huge losses for investors and a slew of foreclosures, kicking off the recession that began in late 2007.

Yet the cash totals now being paid by some of America's largest banks are not nearly enough to reverse the damages caused by the bursting of the housing bubble and the ensuing recession.

Millions of Americans lost their homes in foreclosures and found themselves jobless in the worst downturn since the 1930s. Even as the unemployment rate has clawed back to 6.2 percent from a peak of 10 percent, many people are no better off, as average household incomes after inflation are still lower than what they were seven years ago.

Consumer groups have criticized past settlements for being soft on the banks, noting that top executives at these firms have yet to face criminal charges for the actions of their companies, and for an apparent lack of transparency.

The previous settlements have been of a sweeping nature, releasing the banks from numerous claims by state and federal agencies in exchange for multibillion-dollar cash payments and promises of homeowner aid. "Statements of facts" accompanying the deals refrained from identifying executives involved in the alleged wrongdoing.

Dennis Kelleher, president and CEO of the advocacy group Better Markets, called on the Justice Department for a more detailed accounting of the settlement, urging officials to reveal information on investor losses, the names of any bank executives involved in alleged shady dealings and details on bank profit.

Bank of America had previously argued that it shouldn't be held liable for the subprime mortgages issued by Countrywide and Merrill Lynch, two troubled firms the bank acquired in 2008 as the meltdown took hold. Combined, those three firms issued $965 billion in mortgage-backed securities from 2004 to 2008, according to public records. Roughly 75 percent of that total came from Countrywide.

Last week, in a separate case, a federal judge in Manhattan rejected the claim that Bank of America should avoid penalties for pre-merger actions taken by Countrywide and issued nearly $1.3 billion in fines. The decision said that Bank of America had assumed the legal liabilities of Countrywide after the merger.

A federal jury had earlier found the company and former Countrywide executive, Rebecca Mairone, liable for fraudulently selling troubled mortgages to Fannie Mae and Freddie Mac. Mairone has since been ordered to pay a $1 million fine.