(). (BAC) yesterday struck deals to settle lending (), sell rights to service $300 billion of mortgages and repair relations with regulators. For Chief Executive Officer Brian T. Moynihan, it offers his best chance to rebuild the home lending business.

The firm reached an $11.7 billion agreement designed to resolve most disputes with Fannie Mae two years after Moynihan said the bank “largely addressed” the liabilities. It sold the rights to service about 2 million mortgages, and with 9 other banks, will pay $8.5 billion to end reviews of foreclosure-abuse claims stemming from a 2011 deal with regulators.