Cities and towns across the state are diverting large sums of money to “rainy day’’ accounts even as they lay off employees and make deep cuts to schools and services, girding for what many believe will be a long period of austerity.

Municipal leaders give a variety of reasons — cuts in state aid, anticipated increases in health care costs, dwindling federal stimulus funds — but the financial stockpiling is also a signal they fear the funding enjoyed before the financial collapse will not return anytime soon.

“This is the new normal,’’ said Mayor Dean J. Mazzarella of Leominster, which set aside $3 million this year while it also made sharp cuts that included layoffs. “And we need to adjust.’’

The increase in savings is significant — even surprising. Municipalities saved, on average, more than 6 percent of their fiscal 2009 budgets, the highest rate since at least 1994.

The amount that municipalities held in surplus funds, some $1.35 billion, represents a 50 percent increase from 2005, according to the most recent figures from the state Department of Revenue.

State revenue officials have not yet com piled municipal savings for the 2010 fiscal year, but a Globe survey of 19 cities and towns across the economic spectrum found that all had continued to save at similar rates.

“Communities have been extremely prudent because they know further local aid cuts are coming,’’ said Geoffrey C. Beckwith, executive director of the Massachusetts Municipal Association, which represents cities and towns. “They want a buffer.’’

In Fitchburg, Mayor Lisa Wong said the city has cut 25 percent of its public safety staffing and 15 percent of its teachers in the past three years, and still faces a multimillion-dollar deficit. Yet the city, which relies on the state for half its budget, has saved $3 million over that span to avoid more drastic cuts in coming years.

“Right now, I am closing the library four days a week,’’ she said, which saves the city $800,000 a year. “But if we spend that money rather than set it aside, the city might eventually have to close it entirely. I have eliminated top-level positions in the police and fire departments so later I don’t have to close stations.’’

East Bridgewater’s savings have surged over the past three years to around $5 million.

“Since the state is out of control in the way they dole out their money, you have to solidify your own finances,’’ said George Samia, town administrator in East Bridgewater, which this year froze wages for municipal employees to avoid layoffs, yet still steered $500,000 into savings. “Things are so volatile, trying to come up with a budget is like setting a level in an earthquake.’’

Medfield held on to $1.5 million when setting its budget this summer, said Town Administrator Michael J. Sullivan. Spending that money on employee raises and other immediate expenses, he said, would be like using a credit card to pay monthly bills.

“If we spent all that free cash giving raises, where would we get money next year to fund raises?’’ he said.

Joanne Schmidt, president of the Medfield Teachers Union, which agreed to a one-year contract ending in June that gave most members no raise, said people understood that the town’s savings can’t be drained to boost teachers’ salaries.

“But I don’t think members will be able to get by another year without a raise,’’ she said.

In Leominster, unions have grumbled about the city’s fiscal caution. “Everyone looks at that money and says, ‘Why should we have any layoffs?’ ’’ Mazzarella said. “But if you have nothing to fall back on, you’re in trouble.’’

Boosting reserves, he says, will lower debt payments, secure a better bond rating, and strengthen the city’s finances over the long term.

In some communities, financial pressures are testing their resolve to set money aside. For the first time since 2005, they ended the fiscal year in July with less leftover cash than the previous year. And some communities say they can barely make ends meet now, much less afford to save for the future.

Fall River, for example, has spent nearly its entire $7 million in surplus cash in the past year.

“The $7 million is gone,’’ said Shawn Cadime, the city administrator hired this spring. The money was used for outstanding deficits in the water and sewer department, audit processing, training, and other purposes, he said.

This year, several unions, including clerical and firefighters, have taken 8 percent cutbacks to avoid layoffs. The pay cuts are due to be restored July 1.

Other cities have been forced to draw down reserves they had taken pains to build up. Somerville, which as recently as five years ago had virtually no savings, amassed roughly $3 million by 2009. But this year the city, after eliminating positions and outsourcing jobs like street sweepers and school custodians, reluctantly withdrew $1 million from its rainy-day fund for general expenses. “It’s raining,’’ said city spokesman Michael Meehan.

In Boston, the city has steadily increased its reserves, from about $63 million in 2007 to nearly $139 million now. The city is using $45 million of that to fill budget holes this year, said Samuel R. Tyler, president of the Boston Municipal Research Bureau.

Many communities note that bond agencies have raised their standards and are now advising towns to hold 10 percent of their operating budget in reserve.

“We’d rather be tight with the budget than tap into the savings,’’ said Edward J. Gibson, mayor of West Springfield. “Especially if you see a dark curtain coming.’’

With local aid having plunged by $700 million in the past two years, that’s a common perception.

“They know what’s coming,’’ Jim Stergios, executive director of the Pioneer Institute, said of Massachusetts communities. “They know the stimulus money is gone, and that in 2011 and 2012, they’re going to get hammered.’’