GROTON, Conn. — States with large military bases are filling what is traditionally the federal government's role by picking up the tab for construction and repairs, saying they can't afford not to.

The number of states willing to spend taxpayer money to fix infrastructure in military facilities, and the scale of the projects, has increased steadily in the past five years. State officials argue that the Pentagon keeps asking for base closings, and they want to protect their bases and the revenue they bring in.

Essentially, states are treating their bases like large corporations they want to keep within their borders, and at least one high-ranking Navy official says it's a good idea. Connecticut has been a leader, setting aside $40 million to improve aging infrastructure at the naval submarine base there, much like it's also spending hundreds of millions of dollars to keep companies in Connecticut and create jobs.

"We are changing the ways we think about military bases," said Bob Ross, executive director of Connecticut's Office of Military Affairs. "These are big commercial enterprises. They are publicly financed, but there is so much commercial activity that goes on at these bases, you have to look at them the same way you look at a corporation."

Of the nearly two dozen states where the military has a major presence, slightly more than half have spent state money to fix infrastructure on military installations, the Association of Defense Communities has found. Most of the spending occurred after 2009, when the Defense Department's budget for military construction began shrinking, said Tim Ford, the association's chief executive officer.

Last year, Massachusetts also authorized spending $177 million on its six bases. Cities are contributing, too: Huntsville, Alabama, paid to build houses on an Army post for high-ranking generals.

Most bases are a community's largest employer, and in many cases are the largest employer in a state, Ford said. They infuse capital into an area through salaries, expenditures and contracts, creating a vibrant economy and tax base and helping other business thrive, he added.

"So now you have this proliferation of other states looking to see how they can provide dollars for their installations," Ford said. "It has started to raise the question of, how far do you go? Where's the point by which you have to draw a line, where this is a federal action, this is our federal government, our military, and how much should states really invest?"

States are throwing their money away because these projects won't be enough to change minds in a future round of base closings, said Jerry Hendrix, of the Center for a New American Security, a Washington think tank on national security and defense policies.

"States should spend money investing in the local community, in health and public safety, and what money they don't need should return to their people in the form of lower taxes," said Hendrix, a retired Navy captain and director of the center's Defense Strategies and Assessments Program.

There also isn't the political will to close bases now, Hendrix said, so states are spending money to "compete in a competition that hasn't been declared."

Dennis McGinn, the assistant secretary of the Navy for installations, said he would encourage states to invest in their bases to jumpstart projects. Limited military construction funds are being prioritized, he added.

"It is a great win-win partnership. There's benefit to the state and the local communities. There's benefit, certainly, to the United States Navy and the Marine Corps where states are doing that," McGinn said in an interview when he visited the submarine base in Groton last week.

Connecticut presented McGinn with an offer of $2.2 million for two more projects at the base, and McGinn helped open a new facility for Navy divers, commonly referred to as a dive locker, another project Connecticut paid for.

McGinn said he thinks Connecticut's spending will "absolutely" better position the base should there be another round of base closings. The base was nearly shuttered during the 2005 round, largely because of its aging infrastructure.

"The No. 1 criterion for maintaining a base, instead of closing it or realigning it, is military value," McGinn said. "And the military value of the naval submarine base is enhanced by having, in this particular case, a dive locker."

While Congress has denied the Defense Department's recent requests for base closings, many say more are inevitable. To prepare, Massachusetts is reducing energy costs at its bases to make them more valuable.

Of the states with a major military presence that aren't investing within a base, most have paid for improvements to the schools, roads or housing just outside, the Association of Defense Communities found.

In Virginia, the military installations are in good shape, but the state and local communities have spent more than $140 million to prevent development close to them by purchasing land, said John C. Harvey Jr., the state's secretary of veterans and defense affairs. The legislature also passed a bond authorization in case any infrastructure improvements are needed, he added.

Examples of on-base infrastructure projects funded by state and local governments:

___

ALABAMA: On-post housing. State or local share of cost: More than $5 million.

CALIFORNIA: Electric vehicles project at Los Angeles Air Force Base. State or local share of cost: $3 million.

CONNECTICUT: Facility for Navy divers. State or local share of cost: $4.7 million.

DELAWARE: Major renovations to an Army National Guard readiness center. State or local share of cost: $1.6 million.

HAWAII: Funds for an elementary school on an Army installation. State or local share of cost: $13.8 million.

LOUISIANA: New headquarters for the Marine Corps Forces Reserve. State or local share of cost: $150 million.

MISSISSIPPI: Taxiway improvements at the Combat Readiness Training Center. State or local share of cost: $2.9 million.

OKLAHOMA: Railroad and hangar at Tinker Air Force Base. State or local share of cost: $28 million.

UTAH: Construction of a new gate at Hill Air Force Base. State or local share of cost: $5 million.

___

Source: Association of Defense Communities report, "State of Support: Highlights of State Support for Defense Installations," December 2014