He was fiercely competitive and carefully protective of his reputation. Asked to throw out the first pitch at the 2008 World Series, he brought his security detail to Washington’s stadium to practice getting the ball over the plate.

Mr. Petraeus had seemed all but indestructible. He had been shot in a training accident, had broken his pelvis in a sky diving mishap and survived prostate cancer. Criticized by the advocacy group MoveOn.org in 2007 as “General Betray Us,” he shrugged off the attack and rallied his indignant supporters. Until Friday, fans speculated that post-C.I.A. he might become president of Princeton University, where he had earned his Ph.D. in international relations in 1987, or conceivably even president of the United States. (He has told friends he will never run for president; to show his impartiality, he did not vote when he was in the military.)

But as the news sent astonished Petraeus watchers to the Web on Friday night, many people discovered a January episode of “The Daily Show,” where Ms. Broadwell, who served on active duty in the Army for a decade and is a reserve lieutenant colonel, made an appearance to promote her book, “All In: The Education of General David Petraeus.”

She recounted how she had first e-mailed Mr. Petraeus about her doctoral dissertation and then showed up in Afghanistan, where he helped her in what she called a mentoring relationship, as he had many young officers. She said she and Mr. Petraeus shared an interest in fitness and that he took her running.

“That was the foundation of our relationship,” she said. From time to time, they would go running in Kabul. “For him, I think it was a good distraction from the war.”

From her many profiles and interviews, Ms. Broadwell, who was born while Mr. Petraeus was a West Point cadet and turned 40 on Friday, emerges as a younger, female version of him: travel to 60 countries; service in intelligence, special operations and with an F.B.I. counterterrorism task force; Harvard degree; wife of a physician; mother of two boys.

In her Charlotte, N.C., neighborhood on Friday night, television trucks converged on her house as curious neighbors stopped by to ask what was happening. One thought it was a crew filming “Homeland,” which is shot in that city. A woman on a bicycle rode by, calling out to the crowd of reporters: “Go home. Go home.”