The wars in Iraq and Afghanistan are winding down, Osama bin Laden is dead, and the federal government is deeply in debt. This spells the end of what was a golden decade for the defense industry.

In the decade since the Sept. 11 attacks, the annual defense budget has more than doubled to $700 billion and annual defense industry profits have nearly quadrupled, approaching $25 billion last year.

Now defense spending is poised to retreat, and so are industry profits. "We're about to go into the downhill side of the roller coaster here," said David Berteau, a defense industry analyst at the Center for Strategic and International Studies.

Congress agreed last month to cut military spending by $350 billion over the next 10 years. The defense budget will automatically be cut by another $500 billion over that period if lawmakers fail to reach a deficit-cutting deal by November.

Defense industry stocks have already begun to suffer; they are lagging the S&P 500 in recent months. During the last defense spending downturn, which lasted from 1985 to 1997, defense stocks underperformed the broader market by 33 percent, according to an analysis by RBC Capital Markets.

The Sept. 11 attacks forced the world's biggest and best-funded military to quickly retool itself. It needed to develop technologies, weapons and strategies to find and fight an elusive network of terrorists that seemed more sophisticated and dangerous than ever imagined.

The U.S. spent $1.3 trillion in the ten years following the attacks chasing al-Qaida and fighting two wars. That was on top of baseline military spending in excess of $4 trillion.

"After 9/11 the floodgates opened," says Eric Hugel, a defense industry analyst at Stephens Inc.

The defense budget grew from $316 billion in 2001 to $708 billion in 2011. Federal spending on homeland security, which includes everything from airport security to border control, also rose dramatically. Last year dozens of federal agencies, including the Department of Homeland Security, spent $70 billion on such programs, according to the Office of Management and Budget. That's up from $37 billion in 2003, the first year after DHS was formed.

All that spending was reflected in the soaring performance of the defense industry, led by the top five defense contractors: Lockheed Martin, Boeing, Northrop Grumman, General Dynamics and Raytheon.

In 2001, revenues for U.S.-based defense contractors totaled $217 billion, according to data compiled by the analytics firm Capital IQ. By 2010 revenues had grown to $386 billion. Profits grew more than twice as fast over the same time period, from $6.7 billion to $24.8 billion. Contractors based abroad, such as BAE Systems, also flourished. BAE was the sixth biggest defense contractor in 2010, with $7.2 billion in U.S. military contracts.

Stock prices of defense companies in the S&P 500 index have risen 67 percent since September 11. The index as a whole climbed 8 percent in that period.

Military spending typically rises during wartime and falls during peacetime. But after Sept. 11, and as the wars in Iraq and Afghanistan evolved, it became clear the country needed to spend money on very different military technologies and strategies.

Fighter jets, missile defenses and other Cold War-era systems designed to deal with the perceived threats of nation-states were less useful. The U.S. military had to increase its ability to find, recognize and track enemies that were scattered in many countries and dispersed among the civilian population.

During the war in Iraq the military realized that it couldn't protect troops from a low-tech, but potent threat: jerry-rigged road side bombs. In Afghanistan, commanders needed ways to find and root out insurgents that had tucked themselves in caves in hard-to-reach mountains.

These challenges led to new hardware. Among the most important:

— Transport trucks that protect troops and supplies from roadside bombs. Mine-resistant, ambush-protected vehicles, or MRAPs, quickly became crucial equipment for the Army. Oshkosh Corp., a maker of these trucks, was the 9th biggest military contractor last year. Before 9/11, it wasn't in the top 20.

— Identification tools. Soldiers now carry small portable devices that identify a person by scanning fingerprints, irises and faces. These devices, made by L-1 Identity Solutions, which was recently acquired by Safran, can weigh as little as 3 pounds, transmit data by several different wireless methods and remember 1 million identities.

— Unmanned aircraft. General Atomics' Predators, drones that can fire missiles, have killed several al-Qaida commanders. Lockheed Martin's RQ-170 Sentinel reportedly kept watch on Osama bin Laden's compound as the raid that killed him was taking place.

Another type of company surged in importance in the last decade: Companies that provide services and support to military operations.

As of March, the Defense Department had more contractor personnel in Afghanistan in Iraq than uniformed personnel, according to a study by the Congressional Research Service. Afghanistan has the highest ratio of contractors to military personnel than any other U.S. war.

This has boosted companies like KBR, once a division of Halliburton. KBR, which builds and maintains military bases and other facilities, had $4.7 billion in military contracts in 2010, up from $860 million a decade earlier.

Analysts say the heavy reliance on contractors should allow the military to wind down spending more quickly, because it is easier to terminate a contract than to reduce uniformed troop levels. Also, the government isn't responsible for pensions, health care and other benefits for contract workers, which should save money.

Equipment spending is already being scaled back. In 2009, funding for the F-22 fighter jet, a $65 billion program, was discontinued. Spending on the F-35 fighter jet is in danger of being cut back. An advanced warship called the DDG1000 has been canceled, and an upgrade to the Bradley tank called the Ground Combat Vehicle may also be scaled back or canceled.

Over the past six months, defense company stocks in the S&P 500 index have fallen 16 percent. That compares with an 11 percent decline for the entire index.

During wartime, when dollars are flowing, the new equipment developed to battle new enemies is used together with the equipment that had been developed for earlier wars. But as budgets shrink this time, some of the technologies that were developed during the past decade, such as the unmanned aircraft, will have to replace older systems entirely.

"The era of manned airplanes should be seen as over," says Michael O'Hanlon, a defense policy expert at the Brookings Institution. "The problem is nobody wants to give up the previously agreed on platform."

Jonathan Fahey can be reached at http://www.facebook.com/Fahey.Jonathan