One of the District’s most notorious landlords must pay former tenants $1.1 million in what city officials described as the largest-ever rent recovery for residents “forced to live in squalor.”

D.C. Attorney General Karl A. Racine (D) on Wednesday announced the settlement with Sanford Capital LLC on behalf of 155 residents at three apartment complexes in Northeast and Southeast Washington.

Racine’s office sued the Bethesda-based company for violating consumer protection laws by failing to provide adequate living conditions for tenants, failing to meet housing and fire codes, and misrepresenting apartments as safe and habitable.

Tenants lived for years in apartments infested by mice and other pests and plagued by mold and raw sewage. Many renters lacked heat in the winter, and some did not have working toilets, stoves or refrigerators, city attorneys said.

At some buildings, Sanford refused to fix broken locks, which allowed drug and gun activity, Racine’s office said. The landlord also failed to maintain fire extinguishers, and smoke detectors were often broken or missing, it said.

The company agreed last year to sell its remaining properties to resolve litigation involving a fourth property, the Terrace Manor complex in Ward 8. As a result of that settlement with Racine’s office, Sanford Capital and its principal, Aubrey Carter Nowell, were required to pay $325,000 in restitution to tenants and stop doing business in the District.

“We want to send a loud and clear message by the series of lawsuits and this settlement that businesses that seek to make a profit off of being slumlords risk their ability of being able to conduct business in the District of Columbia,” Racine said in an interview. “Sanford is going to be out of the District of Columbia.”

Nowell did not immediately respond to an email seeking comment.

Washington Legal Clinic for the Homeless and the Legal Aid Society of the District of Columbia worked with Racine’s office on the case.

The buildings involved are located at 1309 Alabama Ave. NE, 315 and 325 Franklin St. NE, and 4951 G St. SE.

Since 2006, taxpayers have funded Sanford’s operations through housing vouchers and affordable-housing tax credits as it built a network of at least 20 complexes with more than 1,300 units. City officials say the company now owns just two D.C. properties, both under court receivership.

Investigations by The Washington Post and Washington City Paper in 2017 found Sanford tenants living in conditions that violated multiple requirements under the city’s building code.

The investigations also exposed gaps in the city’s housing code enforcement, including how the District continued to spend millions to subsidize rents for Sanford tenants while it simultaneously sued the company over poor living conditions.

The District continued doing business with Sanford despite repeated complaints about its conditions, with city officials at the time citing the dearth of landlords willing to rent to people with housing vouchers — many of whom were otherwise homeless.

In response to media reports, Mayor Muriel E. Bowser (D) ordered inspections in March 2017 of all Sanford buildings, a review that uncovered more than 1,000 violations, and resulted in a change to housing enforcement policies.