Bank of America is set to lose nearly all the mortgage market share it gained by buying Countrywide Financial Corp in 2008, in the latest sign of how painful the acquisition has been for the bank.

The Charlotte, North Carolina bank said this month it is no longer buying mortgages made by smaller banks known as correspondent banks, which accounted for half of its mortgage volume.

Stripping out correspondent lending from the first half of the year would have left the bank's market share at about 8.5 percent, barely above its 7.8 percent market share before buying Countrywide, according to Inside Mortgage Finance data.

Bank of America's correspondent lending business came mainly from Countrywide, which was the largest U.S. mortgage lender when the bank bought it in 2008.

The $2.5 billion purchase saddled Bank of America with more than $30 billion of mortgage losses and legal costs, according to analysts.

It's a total disaster, Guy Cecala, publisher of industry newsletter Inside Mortgage Finance, said of the deal.

In January 2008, the bank said the Countrywide acquisition would make it the largest U.S. mortgage lender and servicer, which would in turn make Bank of America the premier consumer lender overall.

Since then, the bank has lost mortgage market share from exiting businesses like subprime lending and lending through brokers. These types of loans helped make Countrywide the biggest U.S. mortgage lender but also triggered big credit losses for the company.

By giving up correspondent lending, Bank of America is likely to drop one spot to No. 3 in mortgage volume, behind Wells Fargo & Co , which has 25.7 percent of the market, and JPMorgan Chase & Co's 12.7 percent.

In 2007, Bank of America was No. 5 in market share, while Countrywide was No. 1, with 16.8 percent market share.

By shedding correspondent lending, Bank of America is giving up a chance to buy loans made when underwriting standards are solid, Cecala said. The loans typically meet terms laid out by government-controlled mortgage giants Fannie Mae and Freddie Mac, or other government agencies.

But Dan Alpert, managing partner with investment bank Westwood Capital LLC, said Bank of America was making a smart move. These loans typically don't produce a lot of revenue for banks and can be of lesser quality. That's because smaller banks are originating the loans to be sold to other banks, which package them into securities for investors.

By nature, you're going to be less cautious if someone down the line is buying the paper, he said.

WORST YEAR IN A DECADE

Banks are jostling for mortgage market share in a much smaller business now as the housing crisis wears on. Inside Mortgage Finance expects lenders to make about $1.2 trillion in loans this year, down from about $1.5 trillion last year and $2.4 trillion in 2007. There is no question that 2011 will be worst mortgage lending year in a decade, Cecala said.

Bank of America spokesman Rick Simon said the bank will continue to focus on making loans directly to consumers, as part of its strategy to deepen relationships with the 58 million American households the bank does business with.

The bank's total share of the mortgage market will decline, but the bank is hoping to offset some of the loss through the stronger retail focus, Simon said.

With Bank of America exiting the correspondent business, experts said smaller banks will likely sell loans to competitors and to Fannie Mae and Freddie Mac instead.

Wells Fargo was the biggest correspondent lender in the first half of this year, with $56.3 billion in loans, accounting for 37 percent of its total originations.

(Editing by Steve Orlofsky)