Washington: America's most influential Military Officer, General David Petraeus, hangs up his uniform on Wednesday as he prepares for his new job as CIA director.

Petraeus, 58, the leading general of his generation, has left his mark on the military in the post-9/11 era but his legacy as commander in both Iraq and Afghanistan remains an open question.

After 37 years, Petraeus will officially retire from the armed forces at a ceremony at Fort Meyer, near Arlington Cemetery where so many fallen soldiers from current and past wars are buried.

Next week, he will don a civilian suit as he takes the helm at the Central Intelligence Agency, where he will confront some of the same enemies he faced in the military, including Islamist militants from South Asia to the Horn of Africa.

With his acute intellect and celebrity status, the four-star general is revered by some as a hero, but his detractors on the left and inside the military sometimes portray him as a hyper ambitious "King David" with designs on the presidency.

Petraeus made his name in Iraq, taking over in January 2007 when the war appeared on the verge of catastrophe.

Leading a surge of additional troops and encouraging his officers to cut deals with former militants, Petraeus was credited with salvaging the war effort.

The success of the troop surge in Iraq is still under debate, with some critics arguing that violence receded because Al-Qaeda's brutal tactics alienated Sunni tribal leaders.