NEW YORK, July 21, 2011 (AFP) – The big US banks showed signs of resilience in their second-quarter earnings, but the sluggish economy and fallout from the subprime mortgage debacle weighed on profits.

Over the past week, Bank of America reported a whopping nine-billion-dollar loss while Citigroup, Wells Fargo and JPMorgan Chase announced profits which beat analysts’ forecasts.

Morgan Stanley reported a half-billion-dollar loss, mostly due to a one-time charge, and its share price rose. Its rival Goldman Sachs reported a profit of $1.05 billion, falling short of expectations, and its shares sank.

“The operating environment for banks continues to slowly improve but significant challenges remain and the recovery from the financial crisis continues to be uneven across the industry,” analysts at Keefe, Bruyette and Woods said in a research note.

In a positive sign, the banks made progress in getting bad loans off their books, and some reported that lending to businesses was growing despite the faltering economy.

“The growth and loans on the commercial sides are picking up and that is a nice trend to see…. That is what the economy will need to get back on track,” said Jamie Peters, a banking analyst with Morningstar.

The shaky economy — which experienced slower growth in the second quarter due to a variety of factors including the eurozone’s debt crisis and Mideast turmoil — had an adverse impact, notably on Goldman Sachs.

The Wall Street banking titan suffered from a slowdown in trading and a jump in risk-aversion, which caused its second-quarter revenues to slump 18 percent from last year.

Bank of America reported the steepest loss, $9.1 billion, largely because of its record-breaking settlement over subprime mortgage claims stemming from the financial crisis.

Other banks are also dealing with hefty legal costs stemming from their actions during the long US housing boom, which ended in dramatic fashion with the 2008 financial crisis.

Wells Fargo, whose second-quarter profits surged 30 percent from last year, was fined $85 million by the US Federal Reserve on Wednesday for deceptive practices in selling subprime mortgages prior to 2008.

Perhaps more importantly, the big lenders are also facing fallout from last year’s foreclosure scandal, in which they were accused of improperly evicting homeowners behind on their mortgages.

They are in talks with the federal government and the states on a gigantic settlement, reportedly around $20 billion, over accusations that they used “robosigners” to approve foreclosures without the proper documentation.

In some cases, homeowners who had made all the payments on their mortgages were handed eviction papers, leading to nationwide outrage.

JPMorgan Chase, widely viewed as the healthiest of Wall Street’s big banks, said last week that its second-quarter profits jumped 13 percent from a year ago to $5.4 billion.

But it also booked an additional $1.3 billion expense for litigation, mostly for mortgage-related problems, and chief executive Jamie Dimon warned that “it will take some time to resolve these issues”.

Citigroup, the global financial services giant that was badly hit by the crisis, said its second-quarter profits were up 24 percent amid strong growth outside the United States.

But its operating expenses rose 9 percent, partly because of legal expenses, which cost Citigroup roughly $900 million in the first half of the year, according to chief financial officer John Gerspach.

“The banks are taking the pain associated with what they wrote during the subprime crisis and trying to move on,” said Morningstar’s Peters.