NEW YORK — President Trump, already saddled with lawsuits and investigations that will follow him when he leaves office, is now facing a legal challenge from former tenants who say he and his family manipulated the cost of apartment improvements to raise their rents.

The group of tenants from rent-regulated apartments that late family patriarch Fred C. Trump once owned are pursuing a class-action lawsuit, alleging a long-running scheme in which a Trump-controlled company, All County Building Supply, artificially adjusted the cost of appliances and other materials to justify raising rents at more than 30 buildings previously owned and managed by the Trumps in Brooklyn, Queens and Staten Island.

The president is a named defendant in the lawsuit, along with his siblings Robert S. Trump, now deceased, and Maryanne Trump Barry, a retired federal judge. The companies that own or oversee the properties now are also named in the suit, because they have benefited from the rent increases that took effect years ago, the complaints says.

The case names 20 plaintiffs who represent a class of victims. It was filed in New York State Supreme Court in Brooklyn.

The lawsuit was first reported by the New York Times.

The allegations stem from a New York Times investigation that exposed a history of alleged malfeasance as the Trump family’s sizable real estate business ballooned into an empire. The conduct alleged in the case began in the 1990s. The Trumps sold off the properties over the next several years.

If the plaintiffs prevail, Trump and the other defendants could owe “many millions” in compensation and damages, said lawyer Jerrold S. Parker, who represents the tenants. The suit alleges that current and former tenants from at least 14,000 apartments were overcharged.

“This is a massive fraud spanning 28 years, victimizing several hundred thousand tenants in Trump regulated apartments and needs to be addressed,” Parker said in statement. “These regulated tenants, many of whom struggle just to pay the rent and put food on the table, must be made whole for the money that was unlawfully and unknowingly taken from them by the Trump family for their own personal gain.”

A spokeswoman for the Trump family dismissed the lawsuit as “completely frivolous.”

“Not only are the allegations completely unsupported by any evidence, but they relate to events which go back nearly 30 years — yet were never once raised by anyone at any time only to be conveniently filed just one month before the 2020 Presidential election,” said Kimberly Benza, the family representative.

The lawsuit alleges that the Trumps illegally raised rents by inflating the costs of apartment improvements. Under New York law, a landlord may increase rents if significant upgrades are made.

The tenants’ lawsuit claims that Trump and his family used All County Building Supply to create doctored invoices reflecting inflated costs of improvements and resold items such as stoves and refrigerators to themselves for more money than they were worth. ­In doing so, the lawsuit alleges, the Trumps had license to increase rents higher than they would have been able to had they paid fair prices for making such improvements.

The lawsuit alleges that President Trump’s late cousin John Walter created the All County invoices, and that Walter and the Trumps would keep the profits.

When Trump leaves the White House next month, he faces numerous other legal battles that began during his presidency, allegations that stem from his past business activity and personal conduct.

Manhattan’s district attorney and New York state’s attorney general both have active investigations into Trump and the Trump Organization.

Also in New York, Trump faces defamation lawsuits brought separately by two women who have accused him of sexual assault. Trump’s niece, Mary L. Trump, also is suing the president and his siblings over an inheritance dispute.

In all instances, the president has denied any wrongdoing.