MBIA story updated with changes throughout.

NEW YORK ( TheStreet) -- Bank of America ( BAC) has settled longstanding litigation with MBIA ( MBI) as it agreed to pay $1.6 billion to the insurer and take a 4.9% stake in MBIA.

The settlement, news of which leaked mid-Monday before it was finally confirmed shortly before the close of trading, sent MBIA shares up by more than 45% , while also giving a boost to Bank America's share price. Bank of America shares rose 5.23% to close at $12.88.

In addition to the $1.6 billion payment and the 4.9% stake, Bank of America will remit to MBIA bonds it purchased through a tender offer that mature in 2034. The bank will also terminate other trades between the two institutions, including credit default swaps it bought from MBIA on commercial mortgage-backed securities (CMBS). Bank of America will also provide MBIA with a $500 million credit line.

Bank of America's stake came at a strike price of $9.59 per share, providing the bank with an immediate windfall since MBIA shares closed at $14.29, up more than 45% on the day. This puts Bank of America "in the money" on the warrants, by $4.70 per MBIA share, or approximately $46.7 million.

The deal proved critical for MBIA, which had been draining much of its cash as it fought Bank of America in the courts. Also as part of the litigation, Bank of America had challenged a restructuring of MBIA intended to separate its municipal bond insurance business from its securitized products division. The securitized products division insured mortgage backed securities that lost most of their value during the subprime housing bust, and so faced billions of dollars in potential claims. MBIA hopes that by protecting the muni bond insurance business from the securitized products business it can once again begin writing municipal bond insurance, a business that remains attractive. Bank of America has dropped the lawsuit challenging the restructuring.

Bank of America has notched some big wins on the legal front over the past week, with several objectors to a key $8.5 billion mortgage settlement dropping out. As with the $8.5 billion settlement, the legal battle with MBIA involves disputed mortgage backed securities (MBS) that bundled home loans extended by Countrywide Financial. Bank of America acquired Countrywide in an ill-fated deal in 2008, and has already paid out or set aside some $30 billion to cover liability for MBS tied to Countrywide.

-- Written by Dan Freed in New York.

Disclosure: TheStreet's editorial policy prohibits staff editors, reporters and analysts from holding positions in any individual stocks.