Watch as coal mines spread across the surface of Wyoming. The state is the nation’s top coal producer.

For a few states, being home to a sizable energy sector has paid off in more ways than one.

Every single state ended the 2013 fiscal year with spare cash, but the ones with the biggest relative stockpiles also happened to be big energy producers. By the time the 2013 fiscal year was over at the end of June, Alaska, North Dakota and Wyoming had the largest year-end budget balances relative to their spending levels, according to a new state fiscal survey from the National Association of State Budget Officers. In each, energy-related industries account for a sizable chunk of economic output and Alaska’s year-end balance of $16.5 billion alone accounted for a fourth of the all-state total.

“There’s a definite connection,” says NASBO Executive Director Scott Pattison. “They basically, through their severance taxes, have built up pretty significant reserves, particularly in Alaska and Texas.” Those two states account for nearly half of the total state year-end balance.

Among the ten states with the largest year-end cushions, relative to what they spend, several are big energy producers. Texas had the seventh largest year-end balance and is the nation’s top energy-producing state, according to the U.S. Energy Information Administration. Wyoming, known for its coal mining, is both the nation’s second-biggest energy producer and had the third-biggest year-end balance. And fifth-biggest producer West Virginia also held the same rank when it came to the size of its year-end budget balance.

But where a few states had exceedingly large cushions, many still have relatively small ones. Alaska’s year-end balance clocked in at 218 percent of its spending. North Dakota’s was 84 percent. But, in 32 states, year-end balances were less than 10 percent of spending. Fifteen of those had budget cushions of less than five percent of what they normally spend in a year. And the rift could continue to grow. The substantial growth in the domestic energy sector is expected to continue for the foreseeable future, affording certain states the ability to cash in by taxing the industry.

But, overall, the situation has improved. The total year-end budget cushion for states peaked at roughly 11.5 percent of average spending by 2006, before falling to 5.2 percent by the end of the 2010 fiscal year. By the end of fiscal 2013, they were back up to 9.6 percent, according to NASBO.