Bank of America Corp. is buying out troubled mortgage firm Countrywide Financial Corp. in an all-stock transaction worth approximately US$4 billion.

The purchase will make Bank of America the largest mortgage lender and loan servicer in the US. Bank of America says it will benefit from Countrywide’s broader mortgage capabilities, including its extensive retail, wholesale and correspondent distribution networks.

Countrywide had US$408 billion in mortgage originations in 2007 and has a servicing portfolio of about US$1.5 trillion with 9 million loans. The purchase also includes Countrywide’s Lender Placed insurance and other businesses.

“Countrywide presents a rare opportunity for Bank of America to add what we believe is the best domestic mortgage platform at an attractive price and to affirm our position as the nation’s premier lender to consumers,” Bank of America chairman and CEO Kenneth Lewis said. “Countrywide customers will gain access to a broad set of consumer products including credit cards and deposit services.”

“We are aware of the issues within the housing and mortgage industries,” Lewis continued. “The transaction reflects those challenges. Mortgages will continue to be an important relationship product, and we now will have an opportunity to better serve our customers and to enhance future profitability.”