For years city officials have lied to cover up squalid conditions in public housing, authorities said Monday in announcing that the de Blasio administration has agreed to pay $2.2 billion to settle a federal probe into the horrendous living conditions in the Big Apple’s housing projects.

The historic deal will ultimately inject up to $4 billion into New York City Housing Authority buildings for improvements, including money from the state, sources said.

Under the settlement, the city will provide $1.2 billion of capital funding to the New York City Housing Authority over the next five years and an additional $1 billion in capital funds over and above what the city has budgeted over a four-year period.

Once that money has been spent, the city has also agreed to pay an additional $200 million per year until the problems are considered fixed and the consent decree is no longer deemed necessary.

Other monies will be coming from the state from a total of $4 billion.

A consent decree hammered ​out​ ​with Manhattan US Attorney Geoffrey Berman also calls for a court-appointed monitor who will oversee the work to ensure it gets done.

“The New York City Housing Authority violates basic health and safety regulations of the U.S. Department of Housing & Urban Development (HUD),” the complaint filed in Manhattan federal court states. “These regulations require NYCHA to protect children from the lead paint that is present within apartments in roughly one-third of NYCHA developments and, more generally, to provide residents decent, safe and sanitary housing. NYCHA has repeatedly made false statements to HUD and the public regarding these issues and has deceived HUD inspectors.”

The deal rejects Gov. Andrew Cuomo’s executive order creating​ ​a new independent emergency manager to oversee the upgrades because the feds were not willing to work with both a state-appointed manager and federal monitor, a person with knowledge of the deal talks told The Post.

As part of the deal, NYCHA admitted failing in its responsibility to remove dangerous lead paint and mold, provide adequate heat, fix broken elevators and keep apartments free of roaches, mice and other vermin.

“This settlement provides a remedy, as opposed to costly, protracted litigation, which would leave NYCHA residents with little to no effective benefit,” a source familiar with the matter said.

The feds’ action capped an investigation that began in 2015, and followed a recent cascade of scandals at NYCHA.

The lawsuit alleges that between 2010 and 2016, at least 19 lead-poisoned children were found to have been exposed to deteriorated lead paint in their NYCHA apartments. “These 19 children are at risk of lifelong neurological problems. But the 19 cases understate the true extent of lead poisoning likely to have been caused by crumbling lead paint at NYCHA,” according to the complaint.

The lawsuit also accused NYCHA​ ​of​ ​falsely certifying that lead-paint inspections had been conducted in 55,000 potentially tainted apartments — and making false statements to HUD and the public about its maintenance work order backlog.

“To fend off concerns by HUD, the media, and local politicians that NYCHA’s large backlog of maintenance work was threatening living conditions at NYCHA, NYCHA began reporting reductions in its backlog,” the lawsuit said.

Long-suffering residents also had to endure widespread boiler failures that left them shivering without heat during the past winter’s worst storms.

Mayor Bill de Blasio defiantly ignored repeated calls for NYCHA chair Shola Olatoye’s ouster — and instead let her force out and demote several underlings — until she finally resigned in disgrace in April.

Monday’s deal is subject to approval by the federal judge who gets assigned the case.