Bank of America Corp reported an $8.8 billion second-quarter loss, its worst ever, and posted a drop in lending margins as low interest rates weigh on the largest U.S. bank.

The results were in the middle of the range the bank forecast in late June when it announced an $8.5 billion settlement with mortgage investors.

The bank's shrinking interest income underscores the difficulties Chief Executive Brian Moynihan faces even as the bank moves past its mortgage problems.

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

Bank of America will not likely be able to boost its dividend for some time, analysts said.

The bank's interest income is under pressure. Its 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 BofA, 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.

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.

Bank of America did post improving credit losses, and some of its businesses, including credit card lending, posted higher profits.

For the second quarter, BofA 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 announced it would take a series of 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.

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.

BofA'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 due to a provision taken as part of the mortgage settlement. Excluding that provision, revenue was $26.5 billion.

Like its peers, including JPMorgan and Citigroup Inc, BofA reported improving credit quality as loan losses continued to decline.

At BofA, 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 BofA to raise its dividend later this year. The bank currently pays 1 cent per share quarterly.

BofA shares were down 3 cents to $9.69 in premarket trading. The shares fell 2.8 percent on Monday and are down 27 percent this year, compared with a 12 percent drop in the KBW Banks Index.

(Reporting by Joe Rauch; editing by John Wallace)