WASHINGTON — 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 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 has not been announced, cautioned that some details still need to be worked out and that the agreement could fall apart. But the person said the two sides reached an agreement in principle after 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 Wednesday. The deal would be the latest arising from the sale of toxic mortgage securities leading up to the recession. Last year, the Justice Department last year reached a $13 billion settlement with JPMorgan, and it announced a $7 billion settlement in July with Citigroup. Each of these deals is designed to offer some relief to homeowners, whose mortgages were bundled into securities by the banks in question and were then sold to investors. When the housing market collapsed, the poor quality of the loans led to huge losses for investors and to a slew of foreclosures, kicking off the recession that began in late 2007. Yet the cash totals from some of America’s largest banks are not nearly enough to reverse the damage 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 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 did not identify executives involved in the alleged wrongdoing. Dennis Kelleher, president and CEO of the advocacy group Better Markets, urged the Justice Department on Wednesday to reveal information on investor losses, the names of any bank executives involved and details on bank profit.Subprime mortgagesThe settlements stem from the sale of toxic securities made up of subprime mortgages. Banks played down the risks of subprime mortgages when packaging and selling the securities to mutual funds, investment trusts and pensions, and to other banks and 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. Those losses triggered a financial crisis that pushed the economy into the Great Recession. Bank of America previously argued that it shouldn’t be held liable for the subprime mortgages issued by Countrywide and Merrill Lynch, two troubled companies 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. Almost 75 percent of that total came from Countrywide.