On Monday, Bank of America (NYSE:BAC) announced that it has reached an agreement with Fannie Mae to settle the companies' dispute over delinquent mortgage loans, which were sold to Fannie by the bank or by its Countrywide subsidiary and that Fannie wanted Bank of America to buy back.

The agreement covers loans worth $1.4 trillion of "original unpaid principal balance" and outstanding principal balance of $300 billion, which were originated by Bank of America or its subsidiary and sold to Fannie between Jan. 1, 2000 and Dec. 31, 2008. Fannie had alleged that Bank of America breached representations and warranties on $11.2 billion worth of these loans.

In settlement of these claims, Bank of America has agreed to pay Fannie $3.6 billion and to buy back $6.75 billion worth of residential mortgage loans sold to Fannie Mae. In a statement, Bank of America noted that it has already taken reserves (charges to earnings) to cover most of the cost of this settlement. Bank of America will be taking a further $2.7 billion pre-tax charge to Q4 earnings to cover the balance of the settlement and to cover the $260 million cost of paying for "substantially all of Fannie Mae's outstanding and future claims for compensatory fees arising out of past foreclosure delays."

Bank of America is also selling the rights to service 2 million residential mortgage loans held by Fannie Mae, Freddie Mac, Ginnie Mae, and other mortgage holders, worth $306 billion.

Bank of America further announced that "independent foreclosure reviews, litigation (primarily mortgage-related), and other mortgage-related matters" will cost it $2.5 billion pre-tax in Q4 2012. Finally, "negative debit valuation adjustments (DVA) and fair value option (FVO) adjustments related to the continued improvement in the company's credit spreads" are expected to cost the bank $700 million pre-tax.

Nonetheless, when all is said and done, Bank of America notes that in part due to the receipt of a $1.3 billion tax benefit from all the above, it expects to be able to report a "modest" profit in Q4 despite the charges.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.