CIA Director David Petraeus has resigned over an extramarital affair, bringing an abrupt end to a brilliant career that saw him serve as military commander in the Iraq and Afghanistan wars.
The revelation shocked Washington just three days after the re-election of US President Barack Obama and shortly before Petraeus had been due to testify on the CIA's alleged failure to properly protect a US consulate in Libya.
"After being married for over 37 years, I showed extremely poor judgment by engaging in an extramarital affair," Petraeus said on Friday in a message to CIA staff, released to the media.
"Such behavior is unacceptable, both as a husband and as the leader of an organisation such as ours."
It was unclear why Petraeus felt he had to step down over the affair, and whether his liaison presented a purely personal problem or raised security issues that could affect his work at the spy agency.
NBC television and other US media reported that the FBI was investigating Paula Broadwell, who is co-author of a detailed biography of Petraeus, "All In," for improper access to classified information.
The resignation comes amid criticism in some quarters of Petraeus over his response to a deadly attack in September on a US consulate in Benghazi, which killed the US ambassador to Libya and three other Americans.
Petraeus was due to face a tough grilling in a series of closed-door classified meetings in Congress next week, with some MPs questioning the former general's handling of the incident.
Michael Morell, Petraeus' deputy at the country's lead spy agency, will serve as acting director and Obama expressed his "utmost confidence" in Morell's leadership.
The most celebrated military officer of his generation, Petraeus, 60, took over at the CIA just over a year ago after retiring as a four-star general.
Obama accepted the CIA chief's resignation after meeting with him on Thursday, hailing his "extraordinary service".
"By any measure, he was one of the outstanding general officers of his generation, helping our military adapt to new challenges, and leading our men and women in uniform through a remarkable period of service in Iraq and Afghanistan, where he helped our nation put those wars on a path to a responsible end," he said.
Senator John McCain, a loyal supporter who championed the general's surge strategy in Iraq, heaped praised on Petraeus for his tenure as commander there.
"General David Petraeus will stand in the ranks of America's greatest military heroes," he said.
"His inspirational leadership and his genius were directly responsible - after years of failure - for the success of the surge in Iraq."
Intensely competitive, he graduated from the US Military Academy at West Point in 1974, where he met his wife, Holly, the daughter of West Point's superintendent.