In a letter released Friday to the Central Intelligence Agency staff, Mr. Petraeus said he told the president of his resignation on Thursday, citing an affair "After being married for over 37 years, I showed extremely poor judgment by engaging in an extramarital affair. Such behavior is unacceptable, both as a husband and as the leader of an organization such as ours," he said in a statement.