It’s definitely not the kind of performance you’d expect from a regulated water utility, since the rates of return are limited by law and every proposed rate increase is vigorously opposed.

But American States Water Co. has been riding a wave of investor enthusiasm.

Buoyed by stronger-than-expected performance from its contracting business on military bases, the San Dimas water services company has seen its stock break free of a five-year trading range and soar to all-time highs in recent weeks. In the process, it has exceeded even the most bullish of analyst projections.

The stock climbed to an all-time high of nearly $52 a share Feb. 6, up 40 percent from its year-ago level.

“It’s been a phenomenal run,” said David Parker, senior utility analyst with Robert W Baird & Co. in New York. Three months ago, Parker issued a report with a “buy” recommendation that forecast the stock would hit a target price of $46 a share this year.

The success can be traced to decisions that American States made in the late 1990s. Frustrated with low rates of return, the company decided to diversify. Other water companies tried; some succeeded, some had to drop their diversification plans.

American States saw an opportunity when the Defense Department launched an initiative to privatize infrastructure services on its military bases. During the next 10 years, the company snagged 50-year contracts at nine bases, mostly to maintain and upgrade water and wastewater services.

These weren’t just any bases: Among them are Fort Bragg, N.C., which in most recent years has been the largest Army base in the world by population, and Fort Bliss, near El Paso, Texas, which is the second largest military base by land area in the United States. American States also won the right to service Andrews Air Force Base in Maryland, famous as the site of presidential flights.

But even as the contracts rolled in, investors remained cautious because the history of utilities diversifying is dotted with failures.

American States Chief Executive Robert Sprowls told the Business Journal last week that it took until 2007 for the company to start turning a profit on the military business. The company spent years evaluating the water and wastewater systems and determining how to set prices. Another reason the military business became profitable is that the company started getting contracts for construction work that was needed to upgrade the systems.

“It took time to get our legs under us in this business,” Sprowls said. “It was a new process for both us and the government, and things went slower than we had hoped.”