WASHINGTON — Fallen CIA director David Petraeus deeply regrets the affair that brought down his glittering career and does not believe he is a victim of political maneuvers, a close associate said.

The resignation of the former general stunned Washington political and intelligence circles, coming just three days after President Barack Obama's re-election and amid a probe into US security failings in Libya.

But retired army colonel Steve Boylan, a former Petraeus spokesman, denied there were political overtones to the resignation, which followed a heated campaign in which the CIA faced questions over its role in a deadly attack on the US consulate in Benghazi.

"My understanding from him is that there is no connection to Benghazi or anything else. He had a wonderful relationship with the White House," Boylan, a close friend who spoke with Petraeus over the weekend, told AFP.

Petraeus had been to testify Thursday at closed door congressional hearings into the deadly September 11 attack, but the Central Intelligence Agency will now be represented by Acting Director Michael Morell, his former deputy.

Boylan said Petraeus did not say whether he would testify at the hearing if asked by lawmakers, though he added: "That's up to Congress."

Top FBI and Justice Department officials are said to have learned of the scandal several months ago but decided to leave both the White House and the congressional committees that oversee their work in the dark until last week.

"He regrets it on so many levels... He regrets the poor judgment and the lack of discipline more than we can probably put into words," Boylan said.

"His words to me were 'I screwed up'."

Boylan said his former boss and his family were devastated over the affair.

Petraeus informed Holly, his wife of 38 years, of the affair before the news broke last week, though Boylan did not know exactly how long she has known.

"To say she is disappointed and furious would probably be a huge understatement at this point," he said.

The couple has two adult children, Anne and Stephen. Their son led an infantry platoon in Afghanistan.

Boylan said the affair between Petraeus and his biographer Paula Broadwell began about two months after he assumed his post at the CIA in September 2011, and thus after he retired from the US Army.

It ended about four months ago, he added.

Petraeus, 60, commanded international troops in Iraq and Afghanistan.

Broadwell, a 40-year-old former army major and mother of two, had close access to the four-star general during several trips she took to Afghanistan to research his biography.

But the months-long FBI investigation found that neither Petraeus nor Broadwell had committed any crime, according to The New York Times and The Washington Post.

Boylan said Petraeus "has always been and he continues to be very careful with operational security and the handling of classified material.

"Based on my conversations with him, he expressed to me that he at no time provided her any classified information."

It all unraveled when a Florida woman went to the FBI in the early summer after she began receiving threatening emails, eventually traced back to Broadwell, accusing her of a flirtation with the general, the Post said.

But Boylan stressed there was "no romantic involvement" between Petraeus and the woman, identified by US media as Jill Kelley, a family friend from his time as the head of US Central Command at MacDill Air Force Base in Tampa.

Boylan, who served as US military spokesman for Petraeus in Iraq during the US troop surge there, described his initial reaction at news of the affair as "disbelief, surprise, shock."

"I would never have expected it," he added. "I was in disbelief, and probably in denial."

The agents eventually discovered sexually explicit emails between Petraeus and Broadwell confirming the affair.

The pair were interviewed separately by investigators in late October and early November.

Broadwell was found to be in possession of some classified material, but Petraeus was cleared of involvement and no criminal charges have been forthcoming.

Petraeus nonetheless resigned. "He just knew that this was the right thing to do because he didn't feel he could lead an organization such as the CIA with this being out there," Boylan said.