Managers at New York City's Housing Authority lied for years about lead poisoning at the nation's largest public housing agency and used a "magic carpenter" and other elaborate ruses to fool federal inspectors, federal prosecutors charged Monday.

The litany of complaints against the housing authority were laid bare in a complaint filed in U.S. District Court in Manhattan by Geoffrey Berman, the U.S. attorney for the Southern District of New York. The complaint was made public after the city and the authority signed a consent decree that will require the city to set aside $2.2 billion over the next 10 years to make the much-needed fixes.

Berman accused the housing authority of underreporting the number of children who have probably been poisoned by lead from peeling paint — and neglecting the 400,000 low- and middle-income people who live in the rotting buildings.

From 2010 to 2016, 19 children were found to have been exposed to deteriorated lead paint in their apartments, the complaint states. "But the 19 cases understate the true extent of lead poisoning likely to have been caused by crumbling lead paint at NYCHA. ... There is every reason to believe the true number of children with lead poisoning is materially higher."

Mold in a housing authority apartment. United States Attorney for the Southern District of New York

Berman, in the complaint, pointed the finger of blame directly at the agency's leadership.

"The problems at NYCHA reflect management of dysfunction and organizational failure, including a culture where spin is often rewarded and accountability often does not exist," Berman said.

"The people who suffer as a result of NYCHA's misconduct are its residents, including lead-poisoned children; elderly residents without heat in the winter; asthma sufferers whose condition is worsened by moldy and pest-infested apartments; and disabled residents without functioning elevators."

From 2010 through 2016, the housing authority submitted certifications to the U.S. Department of Housing and Urban Development claiming that it was in compliance with federal lead paint safety regulations.

Public housing residents listen to Mayor Bill de Blasio at the news conference. Drew Angerer / Getty Images

"But NYCHA has been in violation of the regulations all along, and NYCHA managers knew it," the complaint states.

The agency actually trained staffers how to deceive HUD, providing them with a list of "quick fix tips" for misleading inspectors, according to the complaint.

Geoffrey Berman U.S. Attorney's Office / via AP

Berman will choose the housing authority monitor after he consults with the city, the City Council, the governor's office, and representatives for the long-suffering tenants.

At a news conference at City Hall, Mayor Bill de Blasio said that he welcomed the federal monitor and that what he read in the complaint "made me angry as all hell." But he bristled at suggestions that his administration had failed.

"We can only act on the information we have," he said. "We were not told the truth."

Pressed further, de Blasio apologized to tenants on behalf of the city. But he said the previous administration, the state government and the federal government should also be apologizing for letting tenants down.

Berman has not charged the authority with a crime, but he has not ruled out pursuing criminal charges against individual managers. Among those who could face charges is former Chairwoman Shola Olatoye, who allegedly lied to HUD three times in 2016 about lead poisoning. She resigned in April under intense criticism.

The complaint is the end result of a 31-month investigation that began under Berman's predecessor, Preet Bharara — and that frequently cites the reporting of Greg B. Smith of the New York Daily News.

It makes for grim reading. Among other things, it says:

To prevent inspectors from finding leaky pipes, property managers would simply shut off the water in the buildings — without giving tenants any warning.

Rather than repair broken doors, managers would summon a "magic carpenter" to cover the area with plywood and paint over it "so that the inspector will not know there is a broken door at all."

It was a common practice to stuff holes in the walls, which are breeding grounds for cockroaches and rats, with newspaper and cork and then paint over the holes, to conceal them from federal housing inspectors.

Few of the housing authority workers assigned to deal with lead paint have had any training and many "do not know where the lead paint is."

Many elderly and disabled residents have either been trapped in their apartments for days — or forced to sleep in building lobbies — because the agency was slow to fix the elevators. "In 2016, nearly 70 percent of NYCHA buildings with at least one elevator suffered through an outage during which all of the building's elevators were out," the complaint states.

Confronted with a huge backlog of repairs, in 2012 the authority simply stopped inspecting apartments to avoid creating new work orders.

A year later, it "restored a prior policy that allowed NYCHA staff to close work orders by reporting that the resident was not home when the worker arrived to perform the maintenance work," the complaint states. "This action was taken on the recommendation of a NYCHA executive who explained in an email that the change was being made specifically to reduce backlog numbers."

When confronted with complaints from tenants, lawmakers or reporters, the authority's leaders circled the wagons, Berman wrote.

"NYCHA's response to external inquiries is frequently to cover up or minimize problems that it knows to exist, and executives speaking for the agency (at best) fail to conduct basic diligence before providing HUD and the public false assurances of compliance," the complaint states.

Officials with the housing agency did not immediately respond to requests for comment from NBC News.

In an earlier statement to NBC New York, de Blasio said, "Decades of divestment by the federal and state governments and decades of neglect by New York City government have pushed our public housing system to the brink."

"By further acknowledging and providing solutions to a decades-old pattern of mismanagement, divestment and neglect, I am confident this settlement will be a turning point for our public housing system."