NEW YORK — Bank of America agreed to pay bond insurer MBIA $1.7 billion to settle a dispute over faulty mortgage securities issued during the U.S. housing boom.

In exchange, the bond insurer will drop the litigation it brought against the mortgage lender Countrywide in 2008, according to a statement MBIA released Monday. Bank of America bought Countrywide in 2008.

Also, MBIA will have no further payment obligations on any of its insurance policies held by Bank of America.

Bank of America has also agreed to lend MBIA as much as $500 million and has the option of buying a stake of up to 4.9 percent in the bond insurer.

Unlimited Digital Access. $1 for 4 weeks.

“This comprehensive and important settlement is a very positive step forward for both Bank of America and MBIA,” New York Financial Services Superintendent Benjamin Lawsky, who helped broker the deal, said in a statement. “It resolves significant exposure and expensive litigation for Bank of America, while also giving MBIA a path forward.”

Bond insurers like MBIA and Ambac suffered big losses after the housing crisis. As defaults on mortgages rose, defaults on bonds backed by the troubled loans and insured by bond insurers also climbed. That led to a surge in payouts.

For Bank of America, the agreement is another step forward in its attempt to clear up the legacy of its bad home loans.

In January, the lender reached an $11.6 billion settlement with government mortgage agency Fannie Mae to settle claims resulting from mortgage-backed investments that soured during the housing crash.

In April, Bank of America agreed to settle a class-action lawsuit led by pension funds and other investors who say they were misled about $350 billion worth of mortgage-backed investments they bought from Countrywide.