AUGUSTA — Maine is slated to get $21.5 million from Standard & Poor’s to settle an unfair trade practices lawsuit the state filed against the credit-rating agency.

The settlement was negotiated by the federal Department of Justice and a coalition of 19 states, including Maine.

Maine Attorney General Janet Mills, who announced the settlement in a press conference Wednesday, said the money will go to consumer protection and education efforts, assistance with foreclosure relief, and other initiatives to remediate the effects of the 2008 recession. She said the money is expected to arrive this spring.

“We will not tolerate acts that deceive investors and that devastate our economy,” Mills said outside the Kennebec County courthouse where the press conference was held.

The Maine lawsuit, filed in Kennebec County in February 2013 against McGraw Hill Cos. Inc., and Standard & Poor’s, alleged that actions by the credit rating agency were not objective and were influenced by the firm’s market share and revenue considerations. The credit rating agency’s actions allegedly caused huge losses for pension funds, retirement and other investment accounts, contributing to the financial crisis that led to the recession.

The company is paying $687.5 million to the federal government and another $687.5 million will be divided among the 19 states and District of Columbia.

Mills said the settlement — which gives Maine its largest single settlement in history — ends “a very complex and lengthy lawsuit.”

She said the firm’s actions “contributed greatly to the demise of the housing market in Maine and elsewhere across the country. It contributed to the loss of jobs here in Maine and the loss of houses and the foreclosure crisis both here in Maine and elsewhere, the remnants of which we are still dealing with.” She said the firm inflated ratings for residential mortgage-backed securities and credit default options.

The settlement money will support existing programs and could help people who are in the foreclosure process.

“Our intent is to beef up efforts of foreclosure housing counselors,” she said.

Mills said the federal portion of the settlement will help provide some homeowner relief.

Mills also said she could not comment on whether the state was taking action against any other credit rating agency. She said last year new requirements were adopted by the U.S. Securities and Exchange Commission that deal with conflicts of interest by credit rating agencies.