Now he has followed up with a third book reconstructing the agency’s recent history. “The Shadow Factory: The Ultra- Secret NSA From 9/11 to the Eavesdropping on America,” due out on Tuesday from Doubleday, describes what he sees as the agency’s failures in the months before the 2001 attacks and its overreaching on the orders of President Bush and Vice President Dick Cheney afterward. Two rank-and-file government eavesdroppers who spoke with Mr. Bamford gave interviews to ABC News, where he spent a decade as a producer; the network reported Thursday on their claims of having intercepted private calls home from American military officers, aid workers, journalists and others in Iraq.

“I don’t think I’ll be invited to any more N.S.A. Christmas parties,” Mr. Bamford said, deadpan, sitting down for an interview this week in his Washington town house. At 62, bald and with a salt-and-pepper mustache, Mr. Bamford is so unflamboyant that it comes as a surprise to learn that for most of the 1990s he lived aboard a 60-foot motor yacht called the Safe House, moored in a Potomac River marina.

His relationship with the National Security Agency might be compared to a long and rocky romance, in which fascination with his quarry’s size and capabilities has alternated with horror at its power to invade privacy. But he insists that he is no enemy of the United States’ largest intelligence agency or its mission.

“I have no problem whatsoever with their eavesdropping on terrorists in the U.S.,” Mr. Bamford said. “But the law says they need a court warrant.”

The book depicts the agency before 9/11 under Michael V. Hayden, a now-retired Air Force general who is currently the director of the Central Intelligence Agency, as excessively cautious about legally pursuing terrorists in the United States. He attributes the wariness to the trauma that the agency suffered in the 1970s when a Senate committee exposed the agency’s warrantless surveillance of thousands of Americans, including the Rev. Dr. Martin Luther King Jr. and Jane Fonda.