He rewrote the US manual on counter-insurgency in the bloody early years of the Iraq war, and then implemented his ideas when he was made commander of US forces in the country as the war appeared to be spiralling out of control.
Petraeus’s changes appeared to work. As violence in Iraq abated, the general’s star rose in Washington. He developed a media profile that many politicians would have envied; there was even talk of his running for the presidency in 2012.
He dismissed such talk as absurd, but there is no doubt that some of his fellow generals viewed his public profile with disdain, sniping at him behind closed doors and referring to him as “King David”.
While Petraeus’s arrival in the public consciousness was relatively sudden, within the US military he had long been tipped to rise to the top.
The New York state native graduated from the US Military Academy at West Point in 1974, was the top of his 1983 class at the US Army Command and General Staff College, and went on to earn a PhD in international relations at Princeton University.
He rose to command the 101st Airborne Division during the 2003 invasion of Iraq, but not without brushing with death along the way. In 1991 he was shot in the chest during a training-field accident, undergoing emergency surgery that saved his life.
Nine years later he had another close shave, surviving a parachute accident that left him with a broken pelvis. He refused to let either incident affect his physical training regime; as a keen distance-runner, he prides himself on his fitness, regularly challenging and beating younger men in races.
After leaving his unit, he took over US efforts to train Iraqi security forces, where he was criticised for failing to improve chaotic attempts to build a functioning Iraqi army and police force.
He was then posted back the US, where he began his work on the counter-insurgency manual that would bring him to the attention of policy makers in Washington.
Semblance of stability
With the Iraq war lurching from disaster to disaster, Petraeus was made commander of forces in Iraq in January 2007 with a seemingly impossible mission; to turn the failing war effort around.
Remarkably, he did so, overseeing the arrival of 30,000 additional troops to apply his new doctrine and brokering key deals between US forces and Sunni tribal leaders to undermine Al-Qaeda in Iraq.
Critics argued that he was fortunate to take over in Iraq when he did, because the situation was improving anyway. But as a semblance of stability returned to the country, voices of dissent were largely drowned out by praise.
Petraeus was rewarded for his efforts with command of US forces in the Middle East, a job he is leaving to take over in Afghanistan, where he will once again inherit a stuttering campaign that is fast losing popularity at home.
The task ahead of him will not be easy; but few people know better than David Petraeus that it is at such moments that reputations, as well as wars, are won and lost.