Gen. David Petraeus, center, tours the grounds of the U.S. run Parwan detention facility near Bagram north of Kabul, Afghanistan, in 2010. / David Guttenfelder, AP

by Jim Michaels, USA TODAY

by Jim Michaels, USA TODAY

The resignation of David Petraeus is the latest misstep to befall several top military leaders who were integral to the military engagements that have defined the last decade in Iraq and Afghanistan.

Gen. Stanley McChrystal was forced out in 2010 when he made impolitic remarks about President Obama to a Rolling Stone reporter. Navy Adm. William Fallon resigned in 2008 as commander of U.S. forces after he did the same regarding President George W. Bush in a story in Esquire.

With the departure of Petraeus, the United States has lost one of its most effective leaders in the fight against global terrorism, military leaders and analysts say.

He is credited with turning around the war in Iraq at a time when it seemed destined for catastrophe and with building a road map for fighting counterinsurgencies.

He kept a lower profile at the CIA, but analysts say he was equally effective in taking the fight to the enemy.

Petraeus took charge of Iraq in 2007, leading a surge of forces that stabilized the country and drove violence down.

President Obama turned to Petraeus in 2010 to take over the war in Afghanistan after Gen. Stanley McChrystal was forced out for impolitic remarks he and his staff made to a reporter.

Gen. Jack Keane, a retired Army general and longtime mentor to Petraeus, considers Petraeus "the most accomplished general of our generation" and compared his legacy to that of the renowned battle leaders of World War II.

Petraeus is responsible for "turning around two wars," Keane said. "Only Gen. MacArthur had that opportunity and he only succeeded at one," he said. MacArthur was relieved during the Korean War.

Petraeus rose through the ranks quickly in the U.S. Army, serving in command jobs at all levels.

But unlike many of his colleagues, Petraeus had also earned a PhD at Princeton, where his doctoral thesis examined the impact of Vietnam on the U.S. military command. He attracted a number of intellectually minded officers onto his staff when he took command in Iraq.

Before returning to Iraq to command the surge strategy, Petraeus led efforts to overhaul the military's counterinsurgency strategy, which had been neglected in the wake of the Vietnam war.

The doctrine was a roadmap for how to fight insurgencies, which are often complex and ambiguous forms of warfare.

The U.S. military had shied away from those conflicts in the wake of Vietnam and preferred to fight conventional battles where it could employ superior firepower and technology.

Al-Qaeda's leaders saw that as well and attempted to challenge the United States in ways where its tanks and aircraft would be of little use.

The counterinsurgency doctrine helped the U.S. military shake off the legacy of Vietnam and the confidence to fight its enemies in shadowy wars.

Petraeus was likely attracted to the CIA job because it gave him an opportunity to continue his battle against America's enemies.

"I would surmise Gen. Petraeus is attracted to the agency because the agency is fighting a covert war against Islamic extremism," Keane said in an interview last year.