WHEN THE big bond-rating agencies took Maryland’s financial temperature last month, they found the state in robust health — with the notable exception of Maryland’s undernourished pension fund. The fund needs a sustained infusion of cash if the state is to meet its long-term promises to retired teachers, police, judges and other public employees — a $20 billion infusion, to be precise.

So how did Democrats, who control the state legislature, respond to this red flag? A week after it was raised, they advanced a plan to make the situation worse — to raid the fund in order to forestall cuts in next year’s budget proposed by Gov. Larry Hogan (R). By grabbing pension dollars to plug immediate budget holes, lawmakers would risk the state’s future knowing that most of them will no longer be in office when the bill comes due.

At the turn of the century, Maryland’s pension system was fully funded. But the pile of cash proved too tempting for lawmakers, who began skimming from the state’s annual contributions in 2002. Thus short-changed, and then ravaged by the recession, the pension fund’s value fell to less than two-thirds of its long-term obligations by 2011. That’s when then-Gov. Martin O’Malley (D) struck a deal to add $300 million to the state’s annual contributions in return for workers agreeing to pay more of their wages into the system and accepting lower benefits for newer hires.

The deal put the system on track to reach 80 percent of full funding by 2023; strong stock market returns further fattened the bottom line, which now stands at about $45 billion.

That’s fine, but still $20 billion less than the state has promised its 382,000 current and former employees, many of whom count on monthly pension checks. It’s the seventh-highest pension burden among the 50 states relative to revenues, according to the bond-rating agency Moody’s.

Nonetheless, bad old habits — raids on money earmarked for the fund — returned last year and now seem to be accelerating.

In an effort to block relatively modest budget cuts proposed by Mr. Hogan, mainly to schools and public employees’ wages, Democratic lawmakers in Annapolis are pushing a plan to revamp the formula for scheduled contributions. According to Comptroller Peter Franchot, one of the few prominent Democrats who opposes the scheme, it would shift $2 billion into the general budget over the next decade, then cost the state $4.5 billion in the following dozen years — meaning Maryland would face a net $2.5 billion in additional costs over time in order to keep its pension promises.

That boils down to a short-term payoff to core Democratic constituencies, especially teachers unions, that will burden taxpayers down the road. And if the pension fund’s investments underperform officials’ rosy projections, the result will be fiscal calamity — and big trouble for the employees the legislature is purporting to help.