[What you need to know to start the day: Get New York Today in your inbox.]

The federal government seized more control over the New York City Housing Authority on Thursday, reaching an agreement with the city intended to correct years of mismanagement that prosecutors said had exposed hundreds of thousands of residents to lead paint and other health hazards.

The settlement meant Mayor Bill de Blasio avoided the embarrassment of a complete management takeover of the city’s housing authority, the nation’s largest and oldest public housing system, home to more than 400,000 low-income New Yorkers.

But as part of the deal, the mayor accepted the appointment of a powerful federal monitor and committed the city to spending $2.2 billion over the next decade to repair the authority’s dilapidated buildings.

The agreement also will lead to the replacement of the authority’s interim chairman, Stanley Brezenoff, whom the mayor brought in last year to steer Nycha after a lead paint scandal and the departure of the authority’s chairwoman.