Defense stocks are on the offensive.
Investors seem to be betting that the U.S. defense industry has so far waged a successful campaign against looming budget cuts to secure a profitable peacetime footing after a decade of war.
But it remains to be seen whether these companies can offset tens of billions in shrinking orders for swords with new, long-term contracts for plowshares.
For the moment, investors seem to be overlooking expected cuts in military spending. As defense contractors continue to churn out solid earnings and dividends, their stocks are reaching new highs. Teledyne Technologies, Boeing, Northrop Grumman and United Technologies have hit record highs. Lockheed Martin, General Dynamics and Rockwell Collins are within 10 percent off their all-time peaks.
Analysts say several powerful forces are at work offsetting the heavy headwinds of military spending cuts.
(Read more: How Boeing came back from the brink)
For one thing, many of these companies squirreled away large piles of cash during the boom years knowing that the wartime spending surge wouldn't last forever. At a time when record low interest rates have left investors with few places to find a reliable return, those balance sheets are helping to fund a steady stream of dividends and stock buybacks.
"(These stocks provide) good cash returns to shareholders at a reasonable price where other higher yielding groups are a lot more expensive," said Carter Copeland, a defense industry analyst at Barclays.
As Pentagon spending has slowed, the defense industry has also been beefing up commercial contracts with civilian customers to offset the squeeze brought by the drawdown of two wars and Washington's ongoing deficit cutting.
As military orders have peaked, for example, demand for commercial aviation is taking off. Since the global economy began pulling out of the deep nosedive of the Great Recession in 2010, airlines around the world have been expanding capacity and looking to cut rising fuel costs by replacing aging fleets of gas guzzlers with high-efficiency aircraft, according to a recent report by Deloitte. Boeing estimates that over the next two decades, more than 35,000 new airplanes will be built, driving production to record levels, according the report.
Demand for those new airplanes—and the parts and electronics needed to make them—has helped boost the aerospace and defense industry's overall share of revenue coming from commercial orders. Last year, defense orders accounted for just 54 cents of every dollar of industry revenue, down from 60 cents in 2010.
The transition to peacetime federal spending levels has also been eased by the defense industry's huge backlog of orders, which rose by nearly 6 percent last year to $2.3 trillion, according to Deloitte. Order backlogs at General Dynamics, Lockheed Martin and Northrop Grumman alone amounted to more than $165 billion in the first quarter of this year—more than 18 months' worth of those companies' annual revenues, according to Barclays.
Some defense companies are also working to offset federal spending cuts by expanding sales to civilian customers looking for products and services such as information technology and communications electronics. U.S. defense contractors have also boosted revenues by winning new orders from overseas.
But those markets aren't growing fast enough to make up for the shortfall in federal spending, said Michael Lewis, who follows the defense industry at the Silverline Group.
(Read more: US defense companies go on overseas offensive)
"It will help somewhat in filing in the hole that some of these firms face, but it's not going to fully offset the U.S. cutbacks," he said.
Those cutbacks are shaping up as the biggest the industry has faced since the end of the Cold War. Unless Congress acts to revise it, the 2011 Budget Control Act will shrink defense outlays by some $487 billion through 2021, on top of the one-time $42 billion in cuts required by this year's "sequester."
Those cuts are only beginning to move through the lengthy procurement process, so there's still a chance that Congress will balk at slashing military spending. But investors banking on that outcome are making a risky bet, said Lewis.
"There will be tens of billions of dollars in cuts," he said. "The timing is uncertain but once we start to see that happen you're going to see these stocks start to unwind."
A lot depends on how well these companies continue to pay a reliable return at a time when investors have fewer places to turn. Copeland believes their large backlog of orders and piles of balance sheet cash will allow the strongest companies to weather the transition to peacetime spending levels.
"I think there is some downside risk to their business in 2014, but not to an extent that it would call into question the sustainability of their dividend," he said.
(Read more: As Asia rises, US seen arming less of the world)
Investors loading up on defense stocks may also be anticipating the kind of industry consolidation that has accompanied previous transitions to peacetime. As the military spending pie shrinks, smaller players may be gobbled up by their larger rivals, boosting market share and profits for the acquirers.
"People are trying to place their bets as to who's going to lead that charge," said Lewis. "There are a lot of synergies for the prime contractors when they buy a smaller company. They can take out a lot of cost."
—By CNBC's John W. Schoen. Follow him on Twitter