The Pennsylvania budget passed a mere 13 days late this week. That's a lot better than nine months overdue, a record that Gov. Wolf and the legislature seared into the books in vitriol earlier this year.

This time, the Democratic governor and Republican-controlled legislature beat low expectations by working together to pass a budget that, though defective, qualifies as both a spending and a revenue plan.

For the revenue, they tapped a few untested and even dubious sources, including a loan from the state malpractice-insurance fund. They also extended the income tax to state lottery winners, authorized a tax amnesty program, guessed that allowing consumers to buy wine in supermarkets would generate additional revenue, and banked on unreliable proceeds from expanded gambling.

More defensibly, they raised the cigarette tax by $1 a pack, imposed a 55-cents-an-ounce tax on roll-your-own and smokeless tobacco, and added a 40 percent wholesale tax on electronic cigarettes and other vaping devices. They also extended the sales tax to digital downloads and closed a loophole that allowed retailers to keep 1 percent of the tax for themselves.

On the spending side, the budget devotes $200 million more to basic education, which will be distributed based on a formula that is fairer to Philadelphia schools. That's progress even though it's insufficient. It also provides more funding to address the opioid epidemic, which is taking more lives than car accidents in Pennsylvania.

This budget does not do enough to address the structural deficit. But given the excruciating and expensive months of partisan bickering and broken promises surrounding the last budget, it's especially important that this one was passed (almost) on time. That happened partly because neither the governor nor the legislature wanted to reenact the stalemate that had sent their approval ratings plummeting.

Wolf secured the deal by agreeing to a compromise spending plan, allowing it to become law without his signature and expressing confidence that the legislature would come up with a responsible revenue plan to match it. That was a leap of faith that counted on Republicans to put together a revenue proposal that wouldn't force him to make significant spending cuts. With legislators about to face the voters, who will elect the entire state House and half the Senate this year, the governor's gambit paid off.

If this veneer of civility holds up, perhaps both sides can work on other serious fiscal issues, such as making the natural-gas industry shoulder its fair share. The industry's power was evident even in the final hours of these budget negotiations, when lawmakers dropped a proposal to impose a gross receipts tax on gas companies. Pennsylvania's flat, modest personal income tax presents another obvious opportunity to increase revenue, though Republicans have largely refused to consider it.

Nevertheless, because both sides worked together with a minimum of rancor, hopes are unusually high in Harrisburg. Both the governor and the legislature won a chance to rebuild their reputations by doing the work they were elected to do.