Bank of America Corp reported a record quarterly loss of $8.8 billion as persistent mortgage problems and low interest rates squeezed revenue at the largest U.S. bank.

The loss was expected after the bank said in June it would pay $8.5 billion to settle lawsuits from mortgage bond investors and take more than $14 billion of other home loan-related charges. But investors were troubled by indications that a tepid economy is retarding recovery outside of mortgages.

Interest income fell during the quarter, and Chief Executive Brian Moynihan said in a conference call that demand for loans is sluggish and the economy is not improving quickly.

Shares of the bank closed down 1.54 percent at $9.57 on the New York Stock Exchange.

Some of Bank of America's businesses, like credit cards, experienced rising profits and loan growth during the quarter.

It's a tale of two cities, said Jason Ware, equity analyst at Albion Financial Group. You have one that looks like it's starting to make money, and then you have this mortgage business that is still throwing off pretty large losses.

He and other analysts also said Bank of America is not likely to raise its skinny penny-a-share dividend until at least 2012.

One negative sign for the bank is that its loan book shrank, even as many rivals experienced loan growth. Also pressing profits is lending margins, which are shrinking as 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 the shares of many regional lenders. Wells Fargo & Co said on Tuesday that its margins shrank less.

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.

The settlement underscores the pain caused by the purchase of Countrywide Financial Corp in July 2008 by former CEO Kenneth Lewis, as the financial crisis was intensifying. The $4 billion deal saddled the bank with billions in toxic mortgages. Most of the loans related to the $8.5 billion settlement were from Countrywide.

Bank of America received $45 billion in aid through two U.S. government bailouts during the financial crisis, which it subsequently repaid.

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

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

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 investment bank reported fixed income results increased to $2.6 billion in the quarter, up from $2.2 billion a year prior, but down from $3.6 billion in first quarter 2011.

BofA's year-over-year increase in bond trading stood in contrast to Goldman Sachs Group Inc's 53 percent decline in bond trading revenues, a surprise for what was once the largest Wall Street bond trading house.

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 Fed's denial, paired with mortgage woes and a weaker U.S. economy, have pushed shares down 27 percent this year.

Albion's Ware said BofA's shares -- now trading at roughly half their book value -- are not attractive to many investors because of the uncertainties surrounding the bank's mortgage woes.

From a pure price perspective, you would think it's a bargain, but there's just so many red flags right now, Ware said.

(Editing by John Wallace, Robert MacMillan, Andre Grenon and Phil Berlowitz)