BOSTON — In the shadow of giant war machines, a tiny rare butterfly is thriving. Oddly, experts say, the U.S. military gets the credit.

The frosted elfin, which flutters along on a 1-inch wingspan, has found a home at several defense installations because of the way the military manages open spaces, said Robyn Niver, an endangered species biologist with the U.S. Fish and Wildlife Service.

“Military training requires vast open areas, so these bases are some of our last great wild places,” Niver said.

The little brown butterfly has been confirmed at Westover Air Reserve Base and Camp Edwards in Massachusetts; Fort McCoy in Wisconsin; Fort Bragg in North Carolina; and the New Hampshire State Military Reservation, she said.

The common thread among the bases is the way they manage vegetation through controlled burns, which create perfect conditions for the growth of wild blue lupine and indigo, the frosted elfin caterpillar’s two host plants.

The dainty butterflies were first spotted at Westover in Chicopee, Massachusetts, about 20 years ago, said Jack Moriarty, the base’s chief of environmental engineering.

Proper vegetation control is critical for the safety of the massive C5 military transport aircraft that call the base home. If the vegetation is cut too short, it attracts geese and gulls, increasing the risk of aircraft strikes. If it is allowed to grow too tall, turkeys, deer, and coyotes move in. Lupine and indigo are just the right height.

Although there have been anecdotal reports of its presence in the past, the frosted elfin was confirmed at Camp Edwards on Cape Cod just this spring, said Jake McCumber, the Massachusetts Army National Guard’s natural resources manager.

“It was pretty exciting. I was thrilled,” he said.

Although they’ve been on the base about two decades, the frosted elfin population at 60,000-acre Fort McCoy appears to have exploded, said Tim Wilder, the base’s endangered species biologist. An annual count found about 130 of the insects on the base this spring, the most since the survey began in 2009.

Frosted elfins –which have a range from New England to Florida, and as far west as Texas – are not on the federal list of endangered species, but they are headed there, Niver said. Several states already list them as protected, and they have disappeared completely from others.

The hope is that what’s learned about the populations of frosted elfins – and a whole host of other rare insects, birds, bats and turtles that thrive on military bases – can be applied outside the base gates.

“Our next step now is finding out how we can work with other partners besides the military to try to boost numbers of rare species on other lands as well,” Niver said.