This Feb. 2, 2012 file photo shows CIA Director David Petraeus testifying on Capitol Hill in Washington. Petraeus has resigned because of an extramarital affair.

The scandal that made CIA Director David Petraeus resign late last week was not, as some have insinuated, just a private affair that ought not to affect his professional life. It was a potentially dangerous lapse in judgment that might have endangered national security, although an FBI investigation apparently concluded no such damage occurred.

Plenty of foreign powers and unaffiliated enemies of the United States would gladly pay someone to offer sexual favors in exchange for classified information from the head of the nation's top spy agency. News reports so far raise questions as to whether the woman with whom Petraeus had an affair had inappropriate access to classified information, given comments she made during a recent speech at the University of Denver. Also, the strange and apparently harassing emails the woman, Paula Broadwell, who also was his biographer, sent to another woman from a series of dummy Internet accounts may have included attempts to blackmail Petraeus, Fox News reported.

He should have known better. His behavior made resignation the only logical course.

That said, this incident is a tragedy for all concerned, including the American people. Petraeus was a gifted military leader who left his mark on two administrations.

Although President George W. Bush received most of the credit, it was Petraeus who pushed the idea of a counterinsurgency in Iraq when the war was at its lowest point. Helped by a hefty influx of additional soldiers, he focused efforts on winning hearts and minds in Iraq rather than on just killing the enemy. Together with a decision by Sunni sheiks to turn their backs on al-Qaida and support the United States, the tactic turned the course of that conflict.

Later, President Barack Obama used a similar strategy in Afghanistan, with mixed results. But Petraeus' ability to shift focus and apply innovative methods earned him the respect of Republicans and Democrats alike. By the end of his career he seemed to have abandoned his own Iraq strategy in favor of drone strikes on enemy targets, again showing a willingness to adapt to situations.

Some have questioned the timing of the investigation that led to his resignation. It comes just as Congress is preparing an investigation into the terrorist attacks on the U.S. consulate in Benghazi, Libya, which killed the U.S. ambassador and three other Americans. Congress ought to insist that Petraeus, who undoubtedly knows more about that incident than anyone else, testifies despite his resignation. The nation needs to get to the bottom of what happened and whether, as evidence seems to suggest, the military was slow to come to the aid of Americans under attack.

No matter the context, adultery leaves no winners. A Deseret News report on Sunday quoted Dylan Thrasher, a life and relationship coach in San Diego, saying, "The emotional toll is horrendous and the relationship (with the spouse) is never the same; it creates lots of problems."

Some of those problems and complications were manifested in the strange emails from Broadwell to the other woman. Those are bad enough in a personal context. When the affair involves the head of the CIA, it becomes a matter of national significance.