“The N.S.A. had largely been collecting information because it could, not necessarily in all cases because it should,” he says.

The book is to be released next week.

Mr. Morell was a career analyst who rose through the ranks of the agency, and he ended up in the No. 2 post. He served as President George W. Bush’s personal intelligence briefer in the first months of his presidency — in those days, he could often be spotted at the Starbucks in Waco, Tex., catching up on his reading — and was with him in the schoolhouse in Florida on the morning of Sept. 11, 2001, when the Bush presidency changed in an instant.

Image Michael J. Morell Credit... Mark Wilson/Getty Images

Mr. Morell twice took over as acting C.I.A. director, first when Leon E. Panetta was appointed secretary of defense and then when retired Gen. David H. Petraeus resigned over an extramarital affair with his biographer, a relationship that included his handing her classified notes of his time as America’s best-known military commander.

Mr. Morell says he first learned of the affair from Mr. Petraeus only the night before he resigned, and just as the Benghazi events were turning into a political firestorm. While praising Mr. Petraeus, who had told his deputy “I am very lucky” to run the C.I.A., Mr. Morell writes that “the organization did not feel the same way about him.” The former general “created the impression through the tone of his voice and his body language that he did not want people to disagree with him (which was not true in my own interaction with him),” he says.

But it is his account of the Benghazi attacks — and how the C.I.A. was drawn into the debate over whether the Obama White House deliberately distorted its account of the death of Ambassador J. Christopher Stevens — that is bound to attract attention, at least partly because of its relevance to the coming presidential election. The initial assessments that the C.I.A. gave to the White House said demonstrations had preceded the attack. By the time analysts reversed their opinion, Susan E. Rice, now the national security adviser, had made a series of statements on Sunday talk shows describing the initial assessment. The controversy and other comments Ms. Rice made derailed Mr. Obama’s plan to appoint her as secretary of state.

The experience prompted Mr. Morell to write that the C.I.A. should stay out of the business of preparing talking points — especially on issues that are being seized upon for “political purposes.” He is critical of the State Department for not beefing up security in Libya for its diplomats, as the C.I.A., he said, did for its employees.