Bank of America Corp reported its biggest-ever quarterly loss -- $8.8 billion -- as low interest rates squeezed lending margins at the largest U.S. bank.

The loss was widely expected after the bank said in June that it settled with mortgage bond investors for $8.5 billion and was taking more than $14 billion of other home loan-related charges in the quarter.

But the bank's results, including its shrinking interest income, underscore the difficulties Chief Executive Brian Moynihan faces even if the bank moves past its mortgage problems. The bank's shares fell 1.2 percent in early trading.

It's a slow grind for them, said David Hendler, senior analyst at CreditSights in New York.

The bank's credit losses declined during the quarter and some businesses improved their performance, but the economy is not likely to improve much in the short term, Moynihan said on a conference call.

Given Bank of America's mortgage and interest income difficulties, it will not likely be able to boost its dividend for some time, analysts said.

The bank's loan book shrank, unlike many of its rivals, and the longer-term rates at which banks can lend are falling relative to the short-term rates at which banks borrow.

At Bank of America, these factors translated to a 13 percent decline in interest income and a sizable 0.17 percentage point decline in lending margins from the first quarter.

On a conference call, Chief Financial Officer Bruce Thompson said the bank was pretty close to the trough for net interest income, if it was not there already.

JPMorgan Chase & Co reported a similar shrinking in its lending margins last week, which pressured shares of many regional lenders. Analysts had expected rising interest rate margins to fuel higher bank earnings next year.

For the second quarter, Bank of America reported a net loss of $8.8 billion, or 90 cents per share, compared with net income of $3.1 billion, or 27 cents per share, a year earlier. Analysts on average expected a loss of 90 cents per share, according to Thomson Reuters I/B/E/S.

On June 29, the bank said it would take big one-time charges in the quarter related to a settlement with private investors who demanded the bank repurchase toxic home loans held in mortgage-backed securities.

Excluding the charges, the bank earned $3.7 billion, or 33 cents per share, in the second quarter.

Bank of America's shares fell 15 cents to $9.57 in early trading on Tuesday.

CARDS, INVESTMENT BANKING IMPROVE

The results highlight that many of the bank's business units, most notably its credit card and investment banking units, are becoming more profitable.

Global card services reported income of $2 billion, up from $826 million a year ago. Global banking and markets income rose to $1.6 billion from $1 billion.

Bank of America's consumer real estate services unit lost $14.2 billion in the quarter, continuing a series of losses for the business dating back to the 2008 financial crisis.

Overall, revenue tumbled 54 percent to $13.5 billion because of a provision taken as part of the mortgage settlement. Excluding that, revenue was $26.5 billion.

Like its peers, including JPMorgan and Citigroup Inc, Bank of America reported improving credit quality as loan losses declined.

At Bank of America, net charge-offs -- loans the bank is writing off -- declined for the fifth straight quarter, and the bank lowered its loan loss provision.

Earlier this year, the Federal Reserve denied permission for Bank of America to raise its dividend later this year. The bank pays 1 cent per share quarterly.

The company's shares were down 12 cents to $9.60 in morning trading.

(Editing by John Wallace and Robert MacMillan)