VIRGINIA AND MARYLAND, blessed by proximity to the federal spending spigot, relatively strong employment markets and an uptick in tax collections, are among the states that recorded modest surpluses in the budget year that ended this summer. Hold the fanfare, though, because neither has cause to celebrate.

The two states arrived at their surpluses by different routes — Maryland in part by having raised taxes and fees; Virginia by having made more drastic spending cuts and by withholding hundreds of millions of dollars from its pension plan for state workers.

In both cases, the surpluses are modest, amounting to no more than a percentage point or two of state spending. And in both cases, the states’ present and pending obligations have sponged up most of the so-called extra cash. In a budgetary environment that remains severely austere, no one should equate a surplus with a windfall.

In Maryland, Republicans and a handful of maverick Democrats cited the state’s fiscal 2012 surplus as evidence that Gov. Martin O’Malley’s (D) income tax hike on residents making more than $100,000 was unneeded.

Not exactly. The state’s surplus — its revenue was $230 million more than projected in a base general fund budget of about $14.2 billion — looks meager measured against the expected deficit of $712 million in fiscal 2014, which begins next summer.

The loose talk in Annapolis about an unneeded tax hike calls to mind a similar critique in Virginia after then-Gov. Mark R. Warner (D) secured a $1.4 billion tax increase in 2004, the state’s largest. A budget surplus the next year raised howls from Republicans, but the fury faded a few years later when recession sapped state revenue, leaving officials with a $1 billion hole to plug in the commonwealth’s budget.

As it is, Gov. Robert F. McDonnell (R), who has refused to raise taxes, has shortchanged public and higher education. (Virginia’s spending on K-12 education remains below its 2008 level.) And as Mr. McDonnell has repeatedly acknowledged, he has failed to address Virginia’s severe underinvestment in transportation.

That puts Virginia’s surplus — its third in as many years — in the proper context. At nearly $450 million, it sounds substantial and reflects deep cuts to agency budgets. Yet nearly all of it is committed: to the state’s rainy-day fund; to a fund to clean up the Chesapeake Bay; to a health-care fund; and to an account that hedges against the possibility of federal cuts; as well as to cover higher education expenses that went unfunded last year. State employees will get a 3 percent bonus, their first in two years, and the state’s failing transportation system will get $21 million — an afterthought compared to the billions of dollars it needs.

The surpluses in both states are fleeting, reflecting not so much robust economies as successful temporizing under adverse circumstances. Mr. O’Malley and Mr. McDonnell are able managers, but perils remain in both states’ budgetary futures.