THE CIA thought it had a scoop in 1994. Its friends in the Guatemalan Army were bugging the bedroom of Marilyn McAfee, the US envoy to the country, whom they regarded as suspect because she was fighting human rights abuses by the regime.
Eavesdroppers heard her whispering sweet nothings to someone they took to be her secretary, another female diplomat - and the CIA set out to undermine Mrs McAfee by spreading rumours in Washington she was a lesbian.
There was just one problem. The envoy, who was happily married, was not having an affair with her secretary. The microphones had instead recorded her "cooing endearments" to Murphy, her poodle.
The mistake is an example of bungling by the CIA chronicled in Legacy of Ashes, a new history of the agency by the Pulitzer prize-winning author Tim Weiner, who has covered intelligence matters for The New York Times for 20 years. His book draws on 50,000 documents in the CIA's archives, dating back to 1947, the year it was founded, and 300 interviews with staff, past and present, including 10 former directors.
Weiner concludes "the most powerful nation in the history of Western civilisation has failed to create a first-rate spy service" - a failure, he argues, that is a danger to US security. He paints a portrait of a rogue agency that devoted more time to covert action to oust governments than to gathering information about the US's enemies, and which failed to predict every big world event from the outbreak of the Korean War to the fall of the Berlin Wall and the September 11 attacks.
In 1953 the CIA sent its first officer to Moscow, but he was so inept that he was seduced by his Russian housemaid - really a KGB colonel - photographed in flagrante and blackmailed.
During the Korean War, none of the CIA's 200 officers in the capital, Seoul, spoke Korean and many were accused of having fabricated their reports.
The CIA's difficulties in the Middle East are part of a long and undistinguished history. When Iraq invaded Kuwait in 1990, Robert Gates, then the agency's head and now the US Defence Secretary, was at a family picnic.
A friend asked him: "What are you doing here?" Mr Gates said: "What are you talking about?" She replied: "The invasion." Mr Gates responded: "What invasion?"
Copyright © 2007. The Sydney Morning Herald.