Mark Twain may have called Connecticut "The Land of Steady Habits," but its state budget is vulnerable to wild swings of fortune.

Like a spreadsheet pendulum, dependent on personal income, sales and gasoline taxes, the state's annual spending package over the last quarter century has gone back and forth between surplus and deficit.

Connecticut's rebound is part of a national trend that saw revenues expanding at a pace not seen since the Wall Street collapse and housing bubble popped five years ago.

Now a slowly improving state economy has created a $506-million surplus.

The economic resurgence has gifted states from California to Texas to New York with surplus windfalls -- and many are battling over what to do with the extra money in a gubernatorial election year.

It was a billion-dollar budget shortfall that led to Gov. Lowell P. Weicker Jr.'s push for the personal income tax back in 1991.

By the time Dannel P. Malloy took office in 2011, another budget crisis, created by Republican governors and the Democratic General Assembly in the caldron of the sputtering state economy, created a deficit of about $3.4 billion. Malloy and majority Democrats raised taxes by record levels, reduced benefits for unionized state employee benefits and extended borrowing to cover operating expenses.

But even with the resurgence over the last eight months, the projected Connecticut surplus has wavered from $189 million last July, to $135.9 in October, and $272 million as recently as November.

Opposition Republicans warn that Malloy's election-year budget, which includes refunding taxpayers $155 million for sales and gasoline overpayments, will lead to billion-dollar deficits in 2015 and 2016.

"The governor's address emphasized that there is a `surplus' in Connecticut today," said state Sen. L. Scott Frantz, R-Greenwich. "But, where did that surplus come from? Literally just a few months ago, things were so dire in the state of Connecticut that we were talking about emergency rescue plans to prevent another Detroit from happening in Connecticut. So, how is it that we can have a surplus of roughly half a billion dollars?

Frantz, a private banker, criticized Malloy for taking out loans on more money, extending the state's use of Economic Recovery Fund notes from five years ago.

"Roughly $725 million was borrowed from the market, from other dedicated funds or came from accounting changes, thereby creating the surplus of about $525 million," Frantz said. "We have to keep that in mind going forward with every policy decision this year."

David Martin, Stamford's new mayor, who attended Malloy's State of the State and budget proposal last week, said he'd like to see even more commitments to towns and cities from the General Assembly.

"I'd like to see bigger steps, but I also understand we have to be financially and fiscally responsible," Martin said.

Malloy promises that the modest 2.8 percent overall spending increase proposed for this year will keep the state in even fiscal shape in the years after.

The cycle of surplus-deficit, surplus-deficit may continue until Connecticut comes up with a stable way that doesn't depend on the volatility of Wall Street dividends.

Kevin B. Sullivan, the former state Senate president and lieutenant governor who is the current commissioner of the Department of revenue Services, said last week that the projected $506 million surplus reflects an upturn in the economy, plus a tax-amnesty program that was expected to attract a fraction of the $185 million that was eventually remitted.

"We have 11 major taxes and in particular, it was the sales tax and estimated and final income taxes that are running well ahead of the estimated goals," Sullivan said in a recent interview. Traditional withholding taxes, however, are "dramatically" off.

"People did not get bonuses and some of that is structural unemployment," Sullivan said, adding that a possible increase in non-staff contractors or contingent employment might have caused the higher estimated taxes, which are filed quarterly. "All of that is a guess," he conceded.

The projected $506-million surplus comes after lawmakers and Malloy's fiscal triage, which raised taxes to a record level in the "shared sacrifice" of 2010. Malloy says the two-year budget running through June of 2015 will be balanced and should continue for at least two years after.

He calls the proposed rebates of $55 for singles and $110 for joint tax filers, a "shared reward."

Average revenue grew at 5.3 percent and year-end balances in the fiscal year that ended in June, 2013, increased by 23 percent nationwide, setting the scene for this year's surplus.

"State legislators have once again made the tough decisions that are required to balance their budgets in a slowly recovering economy," said William Pound, NCSL's executive director. "The new budgets enacted for the new fiscal year reflect the cautious path that states are taking as they make their way through this economic transition."

The National Association of State Budget Officers recently reported that with "modestly" improving fiscal health, state spending is set to rise across the country.

Only 17 states, including Connecticut, create two-year budgets.

Peter Gioia, an economist who is vice president of the Connecticut Business & Industry Association, representing big and small companies throughout the state, said Friday that he believes the state is safe from the past budgetary schizophrenia if revenue remains as projected and annual spending increases stay around 2.8 percent.

Back when the taxes were being raised in 2011, Gioia anticipated eventual surpluses.

"The first thing that went through my mind was `holy mackerel,' but obviously there is some underlying firepower when you have a massive tax increase, so when you get some positive economic activity you can get a ton of revenue," Gioia said.

It makes sense, he said, to put most of the surplus into the state's emergency reserves and pension funds, where its impact on future expenses can grow.

Gioia said that a method to reduce the volatility of the state's tax structure would be to have a flatter tax, which would remove some of the higher taxes that wealthy and small businesses pay.

But it would affect those with lower incomes who now don't pay any taxes.

Over the last dozen years or so, the state has been taxing higher incomes and leaving those at the bottom with no liability and, in recent years, Earned Income Tax Credits.

"You can change it, but all we've been seeing is the makings of a more-volatile tax structure," Gioia said.

Bridgeport Mayor Bill Finch, who is president of the Connecticut Conference of Municipalities, said that overall, the state's entire tax structure is worth revising, particularly the way that local budgets depend on property taxes.

"This governor knows that if he cuts cities and towns it will only result in the most-regressive tax, the property tax, going up," Finch said. "He knows that and he's protecting us from that eventuality."

A sustainable future

Gioia, the CBIA economist, credited Malloy with cutting back spending in recent years.

His current proposal cuts about $16 million in the current year's programming, which Benjamin Barnes, secretary of the Office of Policy and Management, says are scattered and targeted.

"Most of the cuts were technical in nature," Barnes told reporters last week during a briefing. "They're not necessarily program eliminations. For example, we were able to reduce our debt service because of lower-than-anticipated borrowing costs."

"We think it creates a sustainable budget for the future," Barnes said, adding that deficits predicted on paper to reach a billion dollars in the years after the 2015-2016 budget do not take into account program changes that can be implemented to avoid the red ink.

"Every year we gather here and go through a process of making priorities about what programs we can afford to fund and which ones we can't," Barnes said. "We believe the best way to predict the outcome of that process in the future is to look at how that process has turned out in the recent past."

Barnes said that even though there have been increases in municipal aid and education, as well as human services and the state rollout of the Affordable Care Act, spending has only increased by an average of 2.8 percent.

"We believe we will be able to do that in the future and we believe that we can, if we limit our selves to that and if we have conservative revenue growth that's we've estimated, that we'll be in balance," Barnes said. "Obviously the future is unknown to some degree. We could have a major change in the economy. We could have a recession between now and 2018. There could be a significant economic expansion between now and 2018. In either of those cases we'll have different choices to make. We believe that the recent average growth in spending, if it continues, is sustainable under the current revenue structure that we have, using conservative assumptions about economic growth."