ST. PAUL —Minnesota must pay back an estimated $48 million to the federal government because it improperly dealt out money to certain state chemical dependency treatment providers.

The Centers for Medicare and Medicaid Services told the Minnesota Department of Human Services in May that it must “immediately cease” payments to a group of substance abuse treatment providers formally known as “institutions for mental diseases.” These institutions include hospitals, nursing homes or other facilities that have more than 16 beds and treat people with mental illness or chemical dependency. Federal Medicaid money generally cannot be used to cover treatment in these facilities.

The Centers ordered DHS to return the money it improperly dealt out but did not disclose how much the agency owed. On Monday, a DHS spokeswoman said the agency estimates it owes the federal government $48 million.

The improper payments were made to up to 100 providers since 2014. DHS uses money from a consolidated fund to pay for substance abuse treatment in these institutions, according to the department. The agency pulled federal money from the fund when it should have used state dollars instead.

DHS officials say they told state lawmakers about the payment problem as early as 2016. But the agency did not update its computer systems to fix the issue until May.

The blunder puts Minnesota on the hook for $48 million, which is in addition to another $25.3 million that DHS separately overpaid to two Native American tribes over the past five years for substance abuse treatment covered under Medicaid. The agency allegedly paid the tribes for medication that patients took at home, but at a higher rate, as if they were treated in a clinic.

In sum, Minnesota must repay the feds $73 million because of DHS errors.

DHS in turn wants the Indian bands to pay back the $25 million even though tribal leaders have produced emails in which the agency appeared to tell them to bill at a rate that caused the overpayments.

Agency officials have said they will not claw back the $48 million from the chemical dependency providers because the billing error was made by the department. In a statement, the department said the $48 million repayment was accounted for in the state budget that lawmakers passed in May.

State Sen. Jim Abeler, R-Anoka, said the costly errors will change the way lawmakers look at DHS going forward.

“I can’t think that either caucus, Democrat or Republican, is going to gleefully just want to write a check to these guys for another $500 million next time without really asking a lot of questions,” said Abeler, who chairs the Senate human services reform committee. “Somebody needs to say ‘we need to do better.’ The governor needs to say it, or the commissioner needs to say it.”

Abeler added that incoming DHS Commissioner Jodi Harpstead will inherit “a whirlwind of trouble” when she takes over on Sept. 3.

Harpstead, CEO of Lutheran Social Service of Minnesota, will succeed acting Commissioner Pam Wheelock, who took over on an interim basis in mid-July after former Commissioner Tony Lourey resigned amid a leadership shuffle. Lourey and his chief of staff quit abruptly after his two top deputy commissioners tendered their resignations.

Deputy Commissioners Chuck Johnson and Claire Wilson rescinded their resignations after Lourey quit. On Monday, Wilson resigned for a second time.

DHS is the state’s largest agency. It has a nearly $18 billion budget and oversees a number of programs for Minnesota’s most vulnerable residents.