A record $17 billion is heading out the door of Bank of America and into the hands of a host of state and federal authorities to end multiple investigations into the bank’s sale of faulty mortgage securities.

Bank of America on Thursday became the third Wall Street bank to reach a multibillion-dollar agreement with the Justice Department for allegedly misleading investors about the quality of bonds sold in the lead-up to the 2008 financial crisis.

As with the preceding JPMorgan Chase and Citigroup deals, questions have arisen about how much of the money will make its way to investors who purchased the securities. These are the people directly affected by the alleged misdeeds, but there is no specific carve-out to compensate investors, whereas funds are set aside to provide relief to homeowners and blighted communities.

One select group of investors is receiving some relief: public pension funds.

Almost $1 billion of the Bank of America settlement will go to states — California, Delaware, ­Illinois, Kentucky, Maryland and New York — whose attorneys general were investigating the bank or its Countrywide Financial or Merrill Lynch units. Those state prosecutors have earmarked that money for the retirement funds of teachers, police officers and fire fighters.

“One of the benefits of a resolution like this is we can actually begin to compensate public pension funds that were victims,” Associate Attorney General Tony West said during a news conference announcing the Bank of America agreement Thursday.

Both of the previous mortgage-securities settlements included state allocations that were used to replenish government pension funds ravaged by losses on risky mortgage bonds, West said. More than $1 billion of JPMorgan’s $13 billion agreement last year and $291 million of the $7 billion Citigroup deal in July went to states.

Public pension funds across the country invested heavily in mortgage securities in the run-up to the financial crisis. Returns on the deals were attractive, but the pools of home loans underpinning the securities were flawed.

Lenders provided mortgages to people they knew could not afford the payments, then packaged those troubled mortgages into bonds for sale to unwitting investors. When millions of homeowners defaulted on their loans and the housing market crashed, investors were saddled with billions of dollars in losses.

Soon thereafter, state prosecutors began poring over securities agreements and found evidence that Wall Street banks were well aware that it was garbage, not gold, that they were peddling.

“Bank of America profited by misleading investors about the risky nature of the mortgage-backed securities it sold,” California Attorney General Kamala Harris said in a statement. “This settlement makes our pension funds whole for the financial ­losses.”

California and New York got the most money from the agreement, each receiving $300 million. Harris said California’s share will be split among the California Public Employees’ Retirement System and California State Teachers’ Retirement System. The pension funds took in $200 million from the Citigroup deal and $300 from the JPMorgan one.

Maryland Attorney General Douglas F. Gansler plans to notify all of the government entities that would be eligible to receive a cut of the $75 million the state was awarded through the Bank of America settlement, according to his office.

Thursday’s settlement is the largest penalty a single company has ever paid to the government. It includes a $5 billion penalty paid to the Justice Department and $7 billion earmarked for consumer relief. The deal will send Bank of America’s legal tab from the 2008 crisis soaring to nearly $70 billion.

“We believe this settlement, which resolves significant remaining mortgage-related exposures, is in the best interests of our shareholders, and allows us to continue to focus on the future,” Brian T. Moynihan, the bank’s chief executive, said in a statement.

Bank of America’s legal woes are largely tied to its $2.5 billion purchase of Countrywide, once one of the nation’s largest home lenders, in 2008, and its $50 billion acquisition of Merrill Lynch in 2009.

The majority of the mortgage securities at the heart of the Justice investigation were the product of Countrywide and Merrill Lynch. About $965 million worth of mortgage securities produced from 2004 to 2008 and tied to Bank of America came under investigation, according to estimates from Sanford C. Bernstein analyst John McDonald. Nearly 96 percent of those securities came from Countrywide and Merrill.

Yet prosecutors found evidence that Bank of America also was culpable for misleading investors. The bank acknowledged that a significant number of loans in an $850 million securitization had serious defects that it failed to mention to investors.

“On multiple occasions — when confronted with concerns about their reckless practices — bankers continued to mislead investors about their own standards and to securitize loans with fundamental credit, compliance, and legal defects,” Attorney General Eric H. Holder Jr. said at the news conference Thursday.