CIA Director David Petraeus has resigned over an extramarital affair - which officials say was uncovered by an FBI investigation.
His affair with Paula Broadwell, his biographer and a reserve US Army officer, led him to ask President Barack Obama to allow him to resign. The president accepted.
The 60-year-old general admitted he had shown "extremely poor judgement" in having an affair.
"Such behaviour is unacceptable, both as a husband and as the leader of an organisation such as ours," he wrote.
He had only been sworn in as director of the Central Intelligence Agency on September 6 last year.
Prior to that, he was a four-star general with 37 years' service in the US Army .
His last assignments in the army were as commander of Isaf, the International Security Assistance Force, and commander of US forces in Afghanistan and in Iraq.
The resignation took Washington's intelligence and political communities by surprise, coming as a sudden end to the public career of the best-known general in recent years.
Exchanges between the general and Ms Broadwell, 40, were first uncovered by FBI agents investigating a potential security breach on his computer.
The investigation was launched after a woman, who has not been identified, accused Ms Broadwell of sending her threatening emails, according to officials.
In a statement released after the resignation was announced, Mr Obama hailed the "extraordinary service" of Gen Petraeus.
"David Petraeus has provided extraordinary service to the United States for decades," Mr Obama said.
"By any measure, he was one of the outstanding general officers of his generation."
The president said the CIA's Deputy Director Michael Morell would serve as acting director.
"I am completely confident that the CIA will continue to thrive and carry out its essential mission," Mr Obama said.
Gen Petraeus has been married for 37 years to Holly, who he met when he was a cadet at the US Military Academy at West Point.
Although the president made no direct mention of Gen Petraeus' reason for resigning, he offered his thoughts and prayers to the general and his wife.
He said Mrs Petraeus has "done so much to help military families through her own work. I wish them the very best at this difficult time".
The CIA has come under fire in recent weeks in the wake of the September 11 attack on the US Consulate in Benghazi, Libya, that killed US ambassador Chris Stevens and three other Americans.
Critics have questioned how much the intelligence agency knew about the likelihood and nature of the attack.