Mayor Bill de Blasio agreed Thursday to give a federal monitor sweeping power to oversee the troubled New York City Housing Authority in a deal aimed at remedying horrendous living conditions that have long gone ignored.

The agreement — which all but amounts to a rebuke of de Blasio’s leadership — also requires the replacement of interim NYCHA Chairman Stanley Brezenoff, who the mayor hand-picked and coaxed out of retirement to deal with the scandals left by his previous public-housing chief, Shola Olatoye.

Olatoye resigned in disgrace last year amid widespread calls for her ouster over a scathing report from the city’s Department of Investigation that revealed NYCHA had repeatedly falsified federal lead-paint inspection reports.

The 32-page settlement sets hard-and-fast deadlines for NYCHA to fix problems involving lead paint, mold, rats, broken elevators and leaky pipes.

But it doesn’t increase the $2.2 billion over 10 years that de Blasio previously offered to fix up NYCHA’s dilapidated and dangerous buildings — and which a judge rejected last year as woefully inadequate.

During a news conference with US Secretary of Housing and Urban Development Ben Carson, de Blasio alluded to additional funding to be generated by his “NYCHA 2.0” plan, which would privatize management of 62,000 apartments, about one-third of all NYCHA-owned property.

City Hall says that move would pay for $13 billion of repairs over 10 years through the federal Section 8 rent-subsidy program.

The plan also calls for selling air rights and allowing private development on NYCHA land to pay for another $3 billion in repairs.

The combined $18.2 billion in new money would be added to NYCHA’s current $6 billion repair budget.

But the total $24 billion would still fall short of the $38.4 billion that NYCHA last year said it needs to properly restore the 175,000 apartments in its 325 housing projects over 10 years.

“What we have today creates a very strong path forward, and a very tangible path forward. We wanted to make sure there would be results,” de Blasio told reporters at the federal office building in Downtown Manhattan’s Foley Square.

Carson said he was “very excited about what we have agreed to, because I think it sets a great precedent for what can be done around the country.”

“This has nothing to do with Democrats and Republicans. This has everything to do with the people,” Carson added.

He said the federal monitor would be named “within the next couple of weeks” but didn’t say who, if anyone, was being considered.

Under terms of the agreement, the monitor — to be chosen by HUD and the Manhattan US Attorney’s Office — will have “full access” to all NYCHA property and records.

The monitor can also “communicate with NYCHA officers, employees, contractors, managers, board members or residents, without notice to NYCHA and without NYCHA’s permission or presence,” the pact says.

De Blasio said Brezenoff, an 81-year-old veteran of multiple city and state posts, would depart once a successor was named, but didn’t say when that would happen.

“The search process will begin immediately,” de Blasio said, adding that “Stan will continue to work on a transitional basis as we prepare for a new chair.”

Thursday’s news conference followed a Wednesday night tweet from event planner-turned-local HUD official Lynne Patton, who posted a media advisory about Carson’s planned appearance.

“For the record, the @NYCMayor knows that I truly appreciate the progress both he & Vito [Mustaciuolo, NYCHA general manager] have made with respect to @NYCHA,” she wrote.

“But we ALL agree there remains much work to be done. No one gets awards on my watch for turning heat & hot water back on. Today is about the RESIDENTS.”

Deadlines set forth in Thursday’s agreement require that 50 percent of NYCHA apartments must be lead-free within 10 years, and 100 percent within 20 years.

Within two years, NYCHA also must be correcting 95 percent of mold problems within five days, and fixing 95 percent of leaking pipes within 24 hours.

Manhattan US Attorney Geoffrey Berman said the suit he filed last year would be dismissed, meaning that Judge William Pauley III won’t have to sign off on the settlement.

In November, Pauley refused to approve a consent decree with the city that the feds filed along with the suit, saying it didn’t include enough money to fix the “breathtaking scope” of NYCHA’s problems and suggesting that the feds should instead take over the troubled agency.

Berman said Thursday’s settlement “goes beyond the prior proposed Consent Decree by providing strict, enforceable standards that NYCHA must meet by particular deadlines.”

“This Office has not wavered from its commitment to better living conditions for NYCHA residents,” he added.

City Councilman Ritchie Torres (D-The Bronx), who grew up in NYCHA housing, slammed the deal as “pure garbage “ and said it “isn’t even worth the paper it’s written on.”

“There’s no new money, there’s no new powers. There’s no regulatory relief, there’s no judicial oversight, there’s no enforcement,” Torres said.

“The only institution that could be trusted to hold NYCHA accountable was the courts — and the courts have been shut out of the process.”

A lawyer for the City-Wide Council of Presidents, a NYCHA tenants group, called the funding provided by the deal “still woefully inadequate.”

But lawyer Nicole Gueron said residents “stand ready” to work with the monitor and others to fix the “terrible conditions” at NYCHA.