Virginia Gov. Terry McAuliffe, center, with the members of the state House and Senate who are conferees on the budget bill, in the State Capitol in February. (Bob Brown/Associated Press)

In good economic times, rising tax revenue often leaves state governments with big surpluses. In bad times, slumping receipts can mean deep, painful cuts in the 49 states that require balanced budgets. So when the Great Recession squeezed states across the country, a few stood out for having planned for the worst.

No state took more steps to sock away money for less-flush times than Virginia, which has set aside temporary revenue for decades. Virginia requires state budget planners to save money in good years so it can cover shortfalls in bad years. The state compares volatility in its three largest tax sources — property, sales and individual income taxes — over the long and short term, and saves the difference between the year-over-year growth and the historic average revenue growth.

Virginia is one of five states — along with Tennessee, Idaho, Washington and Hawaii — that go to extreme lengths to mitigate budget ups and downs. Their rules allow them to save for tough times, while preventing them from spending the money on programs that will far outlast the economic upswings. When the recession came, Virginia was able to use about $2 billion it had in its reserves to close budget gaps.

“Whatever policymakers aspire to accomplish, whether that’s through tax policy or spending or long-term commitments, they can be undermined by these wide swings of resources from year to year,” said Brenna Erford, manager of the State Fiscal Health and Economic Growth project at the Pew Charitable Trusts and a co-author of a recent study on state savings plans.