AUGUSTA, Maine — Maine has reached agreement with Merrill Lynch to recover $20 million the state paid to purchase Mainsail II commercial paper last summer, state Treasurer David Lemoine said Thursday.

Lemoine said the agreement restores the state’s long-standing relationship with Merrill Lynch.

The state’s $20 million investment of cash pool funds in Mainsail II left Lemoine in the hot seat when Mainsail II assets were frozen, putting the state’s investment in question.

Lemoine, who has said that a financial adviser from Merrill Lynch advised the treasury that the investment met the state’s criteria, noted Thursday that Merrill Lynch maintains it did nothing wrong “but agreed to repurchase the paper to resolve this disagreement.”

Merrill Lynch said in a statement that “after extensive discussions with the treasurer, we have decided to resolve this matter with the state of Maine and resume our long-standing business relationship.”

Last December, Lemoine blamed bad advice for a $20 million investment gone bad and defended himself before the Legislature’s Appropriations Committee. Senate Republican leaders had called for an investigation into the state treasurer’s investment.

Lemoine told lawmakers that “while it was indicated by the broker that the instrument was asset-backed commercial paper meeting the state’s rating requirements, it was not indicated that Mainsail was a structured investment vehicle which arbitrages between short-term and long-term debt.”

Mainsail II, which attracted Maine and others like Connecticut, Florida, Montana and King County in Washington, was a structured investment vehicle that was operated by British hedge fund Solent Capital Partners.

“We commend Merrill Lynch for the amicable manner in which this settlement was reached. Merrill Lynch is in good standing with the State of Maine, and we look forward to a mutually beneficial future,” Lemoine said in a statement Thursday.

The Democratic speaker of the Maine House of Representatives, Rep. Glenn Cummings of Portland, welcomed the announcement by Lemoine, a former Democratic legislator.

“The return of the $20 million investment is good news for everyone,” Cummings said in a statement. “Treasurer Lemoine has worked extremely hard to ensure that taxpayer resources are handled wisely and invested carefully.”

Cummings also expressed thanks to the office of Attorney General Steven Rowe, another former Democratic lawmaker, “for ensuring that Maine’s taxpayers were treated fairly and for helping to secure the return of their money.”