Mayor de Blasio is attempting a Soviet-style takeover of 1,200 privately-owned co-op buildings in what critics charge is a blatant effort to artificially boost his affordable-housing numbers.

The Stalinesque secrecy of the plot — developed over two years behind closed doors — has alarmed some lawmakers, who wrote to the city last week to put the plan on hold.

The private co-ops were once derelict buildings in neighborhoods like Harlem, Washington Heights and the Lower East Side that the cash-strapped city sold to residents beginning in the 1980s for as little as $250 per unit. The city was happy to off-load the headache properties, which had been abandoned by absentee landlords or seized from tax deadbeats.

They resembled urban war zones, with blown-out windows, no doors, heat or running water and junkies overdosing in the hallways.

Over the years, the homesteaders banded together to create livable apartments, and at the same time revitalized blighted neighborhoods.

Now, the city wants to seize control of what have become valuable assets, and livid residents are preparing for a legal war to stop it.

“Clearly, the city is attempting a land grab and it’s not progressive because [it is] … attacking the property rights of low, moderate and middle income people and trying to take the only thing that they have in the world,” said John McBride, a co-op owner and a leader of the opposition HDFC Coalition.

Another critic is Bill Palma, who lives in a 38-unit Hamilton Heights co-op building alongside neighbors who fled Fidel Castro’s Cuba after the Communists seized private property.

“They’re seeing history repeat itself over here — this time without guns,” said Palma, 55, an MTA supervisor.

Palma and others see the city’s action as purely political. De Blasio has pledged to create or preserve 200,000 units of affordable housing in 10 years — and the controversial plan would add 30,000 units to his inventory.

The co-op buildings are part of the city’s Housing Development Fund Corp. (HDFC) program. It gives homesteaders ownership of blighted buildings, along with certain conditions and enticements: The buildings cannot be sold to developers, co-op apartment buyers are subject to strict income limits, and the buildings receive tax breaks that amount to tens of thousands of dollars a year.

In the past, most of the co-ops were successfully rehabbed and managed, and went up in value. A few flourished, with apartments now selling for $1 million or more.

The city claims that others — 27 percent — are beset by mismanagement or other problems and are in “significant distress.”

The de Blasio Administration is now proposing a battery of stringent new regulations and strict city oversight to fix a system that many HDFC co-op owners say is not broken. Residents urge the city to focus on the failing buildings — and leave the healthy ones alone.

Under the plan, buildings would sign 40-year agreements with the city that would:

Put them under the watch of a non-profit monitor chosen by the city and paid for by the co-op itself.

Force the buildings to raise maintenance charges by at least 2 percent a year.

Give the city monitor authority over co-op board votes, leaving homeowners with little recourse to challenge the monitor’s decisions.

The monitor would approve every co-op sale or lease in the building, including commercial leases that help keep the buildings afloat.

Impose a “flip tax” requiring that 30 percent of the profit from an apartment sale be kicked back to the co-op to help its operation. Some buildings currently get 50 percent, and they consider the revenue stream vital to survival.

For the first time, cap the sale price of all apartments. Under the new regs, the maximum charged for a one-bedroom this year would be $347,636.

In order to get the HDFC buildings to sign on the dotted line, the city would offer a carrot and a stick: Don’t sign and lose your tax break; or sign, and get a better tax break — but give up control of your home.

The city has been planning the changes for two years and only recently began publicly outlining the blueprint at community board meetings and other forums – but only after prodding from worried homeowners who’d gotten wind of the property grab.

A rep from the city Housing Preservation & Development, which administers HDFC, admitted at one meeting that the city spent much of its time trying to bullet-proof the takeover plan from the flood of lawsuits sure to follow.

Co-op owners feel blindsided.

“If the city had come to us at any point and had a real discussion about the challenges facing us and them … we would have wept with joy. Instead, we get a land-grab effort behind our backs that would saddle us with all kinds of unnecessary and expensive oversight while putting all of our revenue streams under government control. No thank you,” fumed one co-op resident.

Many co-ops are already planning to take the city to court rather than be treated “like bad little children who need to be overseen with its monitors,” said Lisa Ramaci, who lives in an East Village co-op.

Reforms were pushed by the non-profit Urban Homesteading Assistance Board, but even that group thinks the city’s plan wouldn’t work because it’s too much of a blanket solution. And it wants the city to go further on some issues — like an even lower cap on sales prices.

The city is currently seeking non-profits to serve as monitors, but critics note that the city does not require them to have any experience.

“We have a management company. We have regular board meetings. We know more about this building than any monitor would learn in the next 30 years,” said Richard James, who has lived in his Washington Heights co-op since 1972.

Not only have unhappy co-op owners formed a coalition to fight the city, but seven City Council members from Manhattan last week penned a letter to the incoming HPD commissioner demanding the agency stop the process to “ensure real meaningful input” from co-op residents.

“There was virtually no consultation with HDFC shareholders as this regulatory agreement was being crafted, and it was essentially sprung on them after it was already completed,” Councilman Corey Johnson told The Post.

The plan would have to be approved by the City Council, and the co-ops believe a measure — likely hidden in a larger, omnibus bill — would be carried by Council Speaker Melissa Mark-Viverito before she leaves office at the end of the year.

A spokeswoman for Mark-Viverito said “We are currently reviewing the administration’s proposal.”

“Unless we take steps to protect our stock of HDFC coops, we risk losing one of the most valuable sources of affordable homeownership in the city,” said Elizabeth Rohlfing, an HPD spokeswoman.