WASHINGTON/NEW YORK (Reuters) - Bank of America Corp reached a record $16.65 billion settlement with the U.S. government to settle charges that it and companies it bought misled investors into buying troubled mortgage-backed securities, helping the bank close a major chapter tied to the financial crisis.

The settlement announced on Thursday by the U.S. Department of Justice calls for the second-largest U.S. bank by assets to pay $9.65 billion in cash to resolve more than a dozen federal and state investigations, and provide $7 billion in help to struggling homeowners and communities.

It is expected to resolve the vast majority of the Charlotte, North Carolina-based bank's remaining liabilities tied to its purchases of Countrywide Financial Corp, once the nation's largest mortgage lender, in July 2008 and Merrill Lynch & Co, six months later.

"I want to be very clear: The size and the scope of this multibillion-dollar agreement goes far beyond the 'cost of doing business,'" U.S. Attorney General Eric Holder said in announcing the settlement.

Bank of America expects the accord to reduce third-quarter earnings by about $5.3 billion before taxes, or about 43 cents per share after taxes.

Chief Executive Brian Moynihan has spent more than four years trying to shed Bank of America of liabilities from the purchases of Countrywide and Merrill, which were made by his predecessor, Kenneth Lewis. In a statement, Moynihan said the accord is in shareholders' best interests.

"Regulators wanted a pound of flesh, and they got it," said Joel Conn, president of Lakeshore Capital, an investment firm in Birmingham, Alabama. He said the accord, while larger than he expected, represents a "major cloud that has been lifted" from the bank.

Bank of America shares rose 31 cents, or 2.03 percent, to $15.83 in early afternoon trading. The settlement's outlines had surfaced earlier in the month, and the formal announcement may increase the chance that many of the bank's mortgage problems are behind it.


BEARING THE BURDENS

The settlement eclipses the respective $13 billion and $7 billion accords that JPMorgan Chase & Co and Citigroup Inc recently reached to resolve similar claims.

It means Bank of America will have paid well over $65 billion to resolve mortgage issues with consumers, investors and government agencies.

Some shareholders still felt as if they were bearing the costs of the mistakes of long-departed officials at Bank of America, Countrywide and Merrill.

"It's a slight disappointment to me that they settled the issue for this much money," said Joe Terril, president of Terril & Co in St Louis, which invests $760 million and owns Bank of America shares.

The government is still examining crisis-era mortgage abuses. While Bank of America's settlement is expected to be the largest, charges could still be brought against Credit Suisse Group AG , Royal Bank of Scotland Plc and others, people familiar with the probes have said.

About $5 billion of the cash portion of the settlement is paid as a penalty to the U.S. Treasury. Other portions will go toward compensating investors, including state pension

funds. Just under $1 billion will be split among six states, including California, New York and Illinois.


MOZILO

Under the out-of-court settlement, Bank of America acknowledged that Merrill Lynch told investors in subprime mortgage bonds in 2006 and 2007 that the loans generally complied with underwriting guidelines, though reviews suggested as many as 50 percent did not.

A statement of facts cites one email in which a Merrill employee wrote: "(h)ow much time do you want me to spend looking at these (loans) if (the co-head of Merrill Lynch's RMBS business) is going to keep them regardless of issues?"

Bank of America also acknowledged that Countrywide did not generally tell investors the extent to which it made exceptions to its own internal guidelines.

The settlement also covered some post-crisis conduct, including Bank of America's admission that from 2009 to 2012 it submitted loans for government insurance under the Federal Housing Administration that did not qualify.

No individuals were charged on Thursday.

But the U.S. Attorney's Office in Los Angeles is preparing a civil fraud case against former Countrywide Chief Executive Angelo Mozilo, who previously reached a $67.5 million settlement with the U.S. Securities and Exchange Commission, according to a person familiar with the matter.

The settlement does not cover the $1.27 billion fraud penalty imposed last month by a federal judge over a fraudulent Countrywide mortgage scheme known as "High Speed Swim Lane," or "Hustle," which Bank of America is appealing.


(Reporting by Aruna Viswanatha in Washington and Jonathan Stempel and Peter Rudegeair in New York; Editing by Karey Van Hall, Susan Heavey and Jonathan Oatis)