A landlord accused of turning an East Harlem apartment building into a “deathtrap” pleaded guilty to criminal charges Wednesday, the Manhattan District Attorney’s Office announced.

Ephraim Vashovsky pleaded guilty to first-degree reckless endangerment, a felony, and misdemeanor endangering the welfare of a child, prosecutors said. Vashovsky, a 49-year-old resident of Brooklyn, was arrested and indicted in July of 2016.

“This landmark conviction establishes for the first time that New York landlords can and will be held criminally responsible for forcing tenants to live in life-threatening conditions,” Manhattan District Attorney Cyrus Vance Jr. said in a statement.

Vashovsky acquired 21 E. 115th St. in May 2014 and almost immediately began pressuring rent-stabilized tenants to move out, prosecutors said. Several tenants accepted buyouts, but the tenants of apartment 5E — a family of undocumented Mexican immigrants with five children ranging in age from 1 to 12 years old — decided they would stay in their apartment because of ties they made in the community, officials said when Vashovsky was indicted in 2016.

The landlord coerced the family by sending goons to harass them at night and threatening to report them as undocumented immigrants, officials said. In the process of evicting the tenants, contractors filed renovation permits with the Department of Buildings and falsely claimed the building was unoccupied, officials said in 2016.

By conducting major construction and demolition projects in the inhabited building, Vashovsky put the family’s lives at risk and endangered his workers, prosecutors said. The work was done in violation of DOB and Department of Housing Preservation and Development regulations, prosecutors said.

Work included removing structural and load-bearing elements as well as removing of fire retardant materials, fire escapes and internal walls and floors, city officials said. Inhabitants of the building were in constant danger of collapse or a fire, prosecutors said.

Vashovsky had planned to convert the building into luxury apartments, prosecutors said. Cases against two contractors tied to Vashovsky — Adam Cohen and Shaoul Ohana — are still open, prosecutors said Wednesday.

“Today’s plea should serve as a dire warning to all unscrupulous landlords who put profits over people and place tenants in harm’s way: New York City will come after you,”

Public Advocate Letitia James said in a statement. “Ephraim Vashovsky, a repeat offender on my Worst Landlords List, led a campaign of extreme tenant harassment, forcing a family with five young children to live in unthinkable and life-threatening conditions.”