When laws are cobbled together at dawn on the last day of a legislative session, Minnesota state and county officials wake up to the kind of headache they've been dealing with this week.

The source of their pain is a tax-bill provision that originated at about 6 a.m. on Sunday, May 18, in an effort to help counties cope with a new three-year limit on levy increases. A single sentence was proposed by a county lobbyist and added to the bill. It relieves counties from "all maintenance of effort and matching fund requirements" in previous law, "including, but not limited to" a raft of services.

The services specified include mental-health and chemical-dependency treatment, library operations, employment and training services and more. "Not limited to" could mean a whole lot more. Jim Mulder, executive director of the Association of Minnesota Counties, said at least $300 million in county spending could be erased by that one sentence.

That would be bad news enough for libraries and for the vulnerable people counties serve -- none of whom had a chance in the wee hours of May 18 to react to the provision.

But there's more: Reducing some matching county spending would either make federal dollars evaporate, too, or would require more state spending. The latter figure could be "as much as $100 million this biennium," Gov. Tim Pawlenty said Tuesday in a letter to legislators.

Ponying up more scarce state dollars is certainly not what Pawlenty had in mind when he insisted at the session's end that levy increases be capped. Neither was it DFL legislators' idea. "The intent ... [was that] this provision would not have an impact on the state budget," four DFL leaders avowed in a letter to Pawlenty on Wednesday.

That letter promises a remedy: quick repeal in 2009 of the county spending language, retroactive to the date of the tax bill's enactment. The promise puts counties on notice that if they reduce the previously mandated spending, they could find themselves in violation of state law.

But, Mulder rightly asks, then what? Will counties that choose to take their chances and cut spending be required to raise levies, months after they are certified? Under the new levy limit, could they? And what about the dilemma that inspired the problematic provision: When the state both limits tax increases and bars spending cuts, what's a county to do?

That question needs a thoughtful answer, not the slapdash one that emerged with the sun on the session's last day. It was one of two tax-bill goofs. The letter legislators sent to Pawlenty also promises action early next session on an agreed-to tax credit for previously uninsured people who buy private health insurance. To GOP chagrin, that credit was omitted; the bill offered a credit to employers instead.

Lawmaking being a human enterprise, mistakes happen. But mistakes are more likely when bills are cooked up behind closed doors, assembled by conference committees in the middle of the night, and rushed to enactment before people who understand their impact have a chance to speak up. Minnesota's lawmakers know better -- and ought to do better.