John Thain may have struck a deal to sell Merrill Lynch to Bank of America at just the right time, and for a whopping 70% premium to boot. That’s because the recent rating downgrade of American International Group may force Merrill to take another write-down on what’s left of its rotting pile of subprime mortgage-backed collateralized debt obligations.

Even after selling off some $30.6 billion in ailing CDOs to private equity firm Lone Star Funds in August at a steep discount, Merrill still has $19.9 billion in mortgage-backed CDOs in its portfolio. Merrill has marked down the value of those CDOs to $8.8 billion—a more than 50% haircut. In a recent regulatory filing, Merrill said it was adequately protected against suffering any sizeable losses on those remaining CDOs because it had purchased $6 billion worth of insurance, or credit default swaps, from “highly-rated non-monoline counterparties.’’ It’s widely believed that the bulk of that insurance was purchased from AIG, which was a prime seller of credit default swaps on CDOs up until the beginning of 2006.

The downgrade of AIG could require the big insurer to cough-up money to Merrill to keep those contracts in place. But with AIG facing the possibility of having to pay $14 billion in additional capital to Merrill and other companies and hedge funds that bought similar credit default swaps, it’s by no means certain the big insurance will be able to meet that obligation.

That’s a big reason Wall Street is so concerned about AIG and the fear that a collapse of AIG could have far greater ripples than Lehman’s bankruptcy filing. AIG and Merrill did not return phone calls seeking comment.

In all, AIG wrote some $79 billion in insurance on CDOs backed mainly by subprime mortgages—selling insurance to financial firms like Merrill, UBS and Calyon. But AIG did much more than just issue credit default swaps on the worst of the CDOs. The total value of AIG’s credit default swap portfolio is $527 billion, according to a regulatory filing. In downgrading AIG on Sept. 15, Standard & Poor’s said: “The primary source of the strain comes from credit default swaps covering multi-sector collateralized debt obligations with mortgage exposure as well as insurance company holdings of residential mortgage-backed securities.”

The need for AIG to make good on all of its credit default obligations it the main reason the insurer is facing a mad dash to raise cash. It’s likely that firms like Merrill will give AIG some time to raise the necessary capital. Squeezing AIG for cash it doesn’t have will only force the insurer’s trading partners to take write-downs and losses on the credit protection it has purchased.

In many ways, this is what happened when tiny bond insurer ACA Capital was downgraded by S&P to junk status last December. The thinly capitalized firm, which insured nearly $30 billion in subprime backed CDOs, couldn’t make good on its capital obligations. The firm’s failure to pay up resulted in a series of big CDO write-downs by Merrill, CIBC and other banks. It looks like history may be repeating itself. But this time the damage will be much worse.

--with David Henry

Before it's here, it's on the Bloomberg Terminal. LEARN MORE