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)

Reid Wilson is the author of Read In, The Post’s morning tipsheet on politics. If you have a candidate for best state, e-mail him at reid.wilson@washpost.com.

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 — sales taxes and individual and corporate 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.

Alaska, Texas, Louisiana and Massachusetts link rainy-day fund deposits to specific revenue sources. When oil severance taxes grow in Texas, for example, the state saves more. Michigan, Indiana and Arizona link deposits to overall economic conditions. Thirty-four states and the District of Columbia set money aside based on other factors, either through static deposits every year, surpluses or specific appropriations from the legislature.

What sets Virginia apart is that lawmakers can use reserve funds to cover half of a mid-year budget shortfall, but the other half must be covered by tax increases or spending cuts. That forces a proactive approach to hard economic times. After a long recession, sunny days are returning, and Virginia’s rainy-day fund is growing once again.

Read more from Outlook and follow our updates on Facebook and Twitter.

Reid Wilson covers national politics and Congress for The Washington Post. He is the author of Read In, The Post’s morning tip sheet on politics.