Ms. Broadwell, a graduate of the United States Military Academy at West Point, spent 15 years in the military, according to a biography that had appeared on her Web site. She spent extended periods of time with Mr. Petraeus in Afghanistan, interviewing him for her book, which grew out of a two-year research project for her doctoral dissertation and which she promoted on a high-profile tour that included an appearance on “The Daily Show With Jon Stewart.”

Married with two children, she has described Mr. Petraeus as her mentor.

Senior members of Congress were alerted to Mr. Petraeus’s impending resignation by intelligence officials about six hours before the C.I.A. announced it. One Congressional official who was briefed on the matter said that Mr. Petraeus had been encouraged “to get out in front of the issue” and resign, and that he agreed.

As for how the affair came to light, the Congressional official said that “it was portrayed to us that the F.B.I. was investigating something else and came upon him. My impression is that the F.B.I. stumbled across this.”

The Federal Bureau of Investigation did not inform the Senate and House Intelligence Committees about the inquiry until this week, according to Congressional officials, who noted that by law the panels — and especially their chairmen and ranking members — are supposed to be told about significant developments in the intelligence arena. The Senate committee plans to pursue the question of why it was not told, one official said.

The revelation of a secret inquiry into the head of the nation’s premier spy agency raised urgent questions about Mr. Petraeus’s 14-month tenure at the C.I.A. and the decision by Mr. Obama to elevate him to head the agency after leading the country’s war effort in Afghanistan. White House officials said they did not know about the affair until this week, when Mr. Petraeus informed them.