Washington ( CNN ) -- Retired U.S. Army Gen. David Petraeus , who served as the top U.S. commander in Iraq and Afghanistan , was sworn in Tuesday as the new director of the Central Intelligence Agency . Petraeus -- sworn in by Vice President Joe Biden at the White House -- succeeds Leon Panetta , who is now the secretary of defense . At a ceremony marking his retirement from the military last week , Petraeus said his journey with the military was not coming to an end , even though he and his wife were `` about to begin an exciting new journey with another extraordinary organization . '' President Barack Obama has cited Petraeus ' experience in working with the CIA on counterinsurgency efforts in the field as a reason for his nomination as the agency 's director . As the top U.S. commander in Iraq , Petraeus was dubbed `` King David '' for turning around what seemed like a losing battle . He took over in Afghanistan in July 2010 after the retirement of Gen. Stanley McChrystal , whose departure came on the heels of unflattering remarks he made about administration officials in a Rolling Stone magazine article . On July 18 , Petraeus handed over Afghan command to Gen. John Allen . Petraeus graduated in 1974 from West Point and began his career as a second lieutenant in the infantry . He went on to become arguably the most influential general of his generation , and Esquire magazine called him one of the most influential people of the 21st century . `` I wanted this job , '' Petraeus said at his Senate confirmation hearing . `` I am taking off the uniform I have worn for 37 years to do this the right way . ''
NEW : Petraeus is sworn in as CIA director . Petraeus succeeds Leon Panetta , who is now the U.S. secretary of defense . Petraeus was the top U.S. commander in Iraq and Afghanistan . He resigned from his position at Central Command on September 4 after admitting to an extramarital affair with a woman while he served there.