RESCUING MARYLAND’S badly undernourished pension system for retired state government workers didn’t rank among the sexiest issues that state lawmakers grappled with this year. Surprisingly, it wasn’t even one of the more controversial, at least on the surface. With minimal ado, the legislature managed to find billions of dollars in long-term savings at the expense of current and future employees, the better to restore the retirement fund’s solvency and slash annual spending.

But the changes were bitterly opposed by the state’s powerful public-sector unions, most of all the 71,000-strong Maryland State Education Association, the teachers union. Having underwritten the campaigns of so many Democratic candidates for so long, the teachers could scarcely believe the lawmakers would turn on them. In the event, that’s just what happened.

This is heartening. Even in a state as heavily Democratic and pro-union as Maryland, it has dawned on elected officials that spending on public employees has spun wildly out of control. The state’s general fund revenue grew by 39 percent in the decade that ended this year; in the same span, spending on pensions and other benefits for state employees grew by 59 percent. And for local employees including teachers, whose pensions are also paid by the state, the cost grew by a staggering 159 percent.

This is unsustainable. The ballooning costs, projected into the future, mean the gap between the state pension system’s assets and liabilities has grown in every year since the turn of the century and has become a chasm. As things stand now, Maryland has just 60 percent of the funding needed to cover the pension and benefit promises it has made to current and future retirees. Eighty percent is considered minimally responsible.

To reach that goal by 2023, the General Assembly adopted a package of reforms that will compel current employees and retirees to pay a greater share of the cost of their benefits while trimming payouts. As the teachers union put it in a summary for its membership: “Everybody pays more, and all of the new people get a lot less.”

The particulars will be painful for Maryland’s 170,000 active teachers and state employees as well as its 120,000 retirees. Current employees will see a squeeze on their paychecks as their contributions to the pension system rise to 7 percent of salary from 5 percent. Cost-of-living increases will be slashed. New employees will have to work longer to qualify for a pension and retire later, and their pensions will be smaller. And retirees will face higher out-of-pocket costs for prescription drugs.

The plan is not a panacea. It is projected to save at least $2.4 billion over the next 12 years, but the state’s annual payments into the pension system will continue rising much faster than revenues or the budget as a whole. And the goal of covering 80 percent of the fund’s liabilities by 2023 depends on what may be an over-optimistic 7.75 percent annual return on the system’s investments.

Trying to head off the legislation, the teachers union for months pursued a strategy of obstruction and denial. When it finally proposed its own cost-cutting scheme, it was too little and too late. The lesson: States cannot indefinitely promise the moon to any interest group, no matter how powerful and deep-pocketed, without the bill coming due eventually.