AUGUSTA — A federal court dismissed a 2012 lawsuit filed by the Maine Association of Retirees over elimination of cost-of-living increases in their state pensions.

The lawsuit, filed against the Maine Public Employees Retirement System, had argued that a measure to save money by eliminating cost-of-living increases for retirees was illegal and in violation of the state and U.S. constitutions. The move had saved an estimated $48 million during the current two-year budget cycle.

“Although one may conclude that it was unnecesary or even unwise for the Legislature to have (made the statutory changes at issue), it is not for this court to substitute its opinion on the merits or desirability of the legislation for that of the Legislature,” Judge George Singal of the U.S. District Court for the District of Maine said in the 24-page ruling.

The plaintiffs in the case also included the Maine State Employees Association, the Maine Education Association and the Maine State Troopers Association. The unions could not be immediately reached for comment.