The resignation of CIA director James Woolsey over the Ames affair is the latest in a catalogue of mishaps for the Agency. Patrick Cockburn reports from Washington
The first secret James Woolsey was told when he took up the job of director of the CIA two years ago was that it had been penetrated by a mole. Aldrich Ames is now in jail serving a life sentence but his exposure - and revelations about the bumbli ng efforts to identify him in the nine years he worked for Moscow - have done more damage than any other of the numerous scandals in the CIA's history.

Mr Woolsey's failure to appreciate the political damage done to the CIA by the Ames case led directly to his downfall this week. It alienated Congressional leaders and undermined popular support. By refusing to fire anybody for the failure to unmask Amesearlier, he led Congress to take the reform of intelligence into its own hands by setting up a non-partisan commission.

Even as the White House was considering Mr Woolsey's letter of resignation sent at the weekend, official Washington was astonished to switch on its television sets and find an hour-long interview with Ames being broadcast on CNN. Speaking from his federal prison in Pennsylvania, he praised his Russian handlers and said there were "probably" other foreign moles still working for the CIA.

The interview did not lead directly to Mr Woolsey's departure. This was the result of mounting pressure from Congress and within the CIA. The White House, which never liked Mr Woolsey very much, was nevertheless upset that he should have chosen this moment to resign when President Bill Clinton is trying to stabilise his administration. Now, on top of all the problems he is facing in dealing with an incoming Republican Congress, he has to find a new CIA director.

The CIA has faced many scandals and failures before. In the early 1960s it tried to assassinate Fidel Castro. In 1973 it helped to overthrow the elected socialist government of Salvador Allende in Chile. In 1986 its director Bill Casey was involved in illegally shipping weapons to Iran, using the money to fund rebels in Nicaragua. But all these efforts, even when laws were broken, could be defended by the CIA and its friends as being the result of excessive anti-Communist zeal.

The Ames scandal is more damaging because it has made the CIA a figure of fun. Since revelations about its agents spying on Americans opposed to the Vietnam war, the Democrats have always regarded the organisation with deep suspicion. But now the CIA is under attack from both left and right.

The CIA's own report on the Ames case showed an organisation that is highly introverted. As Ames admitted this week, he was peculiarly "sloppy". On one occasion he loaned his lap-top to a colleague so that he could play computer games, forgetting that onthe same disk he was storing classified information to pass on to the KGB. The colleague did notice this - including the name of Ames's Russian case officer - but failed to draw any damaging conclusions.

Such episodes have begun to make the CIA a target for cartoonists, eroding its air of mystery and glamour. It has also lost its main enemy with the collapse of the Soviet Union. The same is true of the rest of the American security establishment that grew up after Pearl Harbor to fight the Second World War and the Cold War from 1946 to1991. However, the Pentagon, defending a $270bn (£175bn) budget, has been far more successful than the CIA in fighting off reform. President Clinton recently promised the armed forces an extra $25bn and the incoming Republican leaders say this is not enough.

Why has the CIA been so much less successful than the armed forces in protecting itself against the consequences of the collapse of Communism? The United States now accounts for more than half the world's military expenditure, so it should be easier findarguments for cutting armoured divisions intended to stop a Soviet armoured thrust into Western Europe than to reduce political intelligence in a more fragmented world.

The CIA's inability to argue its case is largely because its reputation has been poor since the 1960s. A defence specialist said yesterday: "Of the national security organisations it has always been the weak sister." Even right-wing Republicans are oftendubious about the CIA, some believing it played a role in bringing down President Richard Nixon over Watergate. In numerous American films the CIA - or some similar federal spying organisation - is almost invariably portrayed as the hidden hand behind events such as the Kennedy assassination.

Its unpopularity is explained by traditional American suspicion of an organisation that is unaccountable to anybody and also by the national fondness for conspiracy theories. But the CIA has also been damaged by its history during the past 10 years, in which time it seemed to bounce back under Mr Casey as the spearpoint of President Ronald Reagan's renewed offensive against the Soviet Union.

After Vietnam President Jimmy Carter and the Democrats had tried to reorientate the CIA away from covert action. In 1980 the outgoing director, Admiral Stansfield Turner, wrote in a memo to the incoming Republicans that the CIA could not "withstand another scandal". When it was returned to him he found a member of the Reagan team had written in the margin: "Too liberal, afraid of political controversy."

As director from 1981 to 1987 Mr Casey, who had once worked for the Office of Strategic Services - the CIA's ancestor organisation - in the Second World War, brought plenty of political controversy and ultimately the scandal Admiral Turner feared. The CIA was vastly expanded. President Reagan raised its director to cabinet rank and the number of its employees jumped from 15,000 to 27,000. The Directorate of Operations, the clandestine side in charge of recruiting agents and covert operations, grew from 3,700 to 6,000 members. For the increased numbers a $3m annexe was built at the Langley headquarters in Washington's Virginia suburbs.

The rapid expansion is now being blamed for allowing Ames and Edward Lee Howard, a former CIA employee who sold secrets to the KGB in the mid-1980s, to operate freely.

This may be so, but the CIA may also have realised that in the 1960s it had been seriously damaged by all-embracing paranoia when one of its most senior officials, James Jesus Angleton, came to believe it had been penetrated by one or more Soviet agents.

Covert action by the CIA in Lebanon, Iran and Nicaragua ultimately tied the CIA into Iran-Contra - the sale of arms to Iran in return for money that would allow the White House to circumvent Congress by supporting the Nicaraguan Contra rebels. Despite e x posure there was no real public or private investigation of the CIA's role in the affair. "When there is no public accountability, and there can't be with the CIA," a former intelligence official was quoted as saying yesterday, "there needs to be interna l accountability, and in recent years there has been almost none."

Many of the vices of the CIA are - going by the record of MI6 - true of any intelligence organisation operating in secret. Both organisations have swung from trusting all long-time employees to suspecting an enemy mole every time anything goes wrong. Lack of accountability for money spent opens the door to wide-scale corruption. A British agent once fabricated a string of well-paid sources in Saudi Arabia. A CIA officer invented six people on the American payroll in Costa Rica.

The CIA also suffered from three politically and organisationally weak directors - William Webster, Robert Gates and Mr Woolsey - after Mr Casey, who died in 1987. The CIA began to be blamed for errors that were scarcely its fault. For instance, it beca m e conventional wisdom that the CIA had underestimated the crisis in the Soviet economy in the 1980s but it is by no means clear that this crisis really existed before the Gorbachev reforms. It failed to predict that Saddam Hussein would move his tanks in to Kuwait in 1990, but then so did everybody else, including the State Department.

It will be surprising if the CIA is reformed much despite the public failures of the past few years. Government institutions in Washington are skilled at surviving threats to their power and the CIA remains an organisation of immense power. The Clinton White House never really gained control of it, as was shown by systematic leaks from the CIA in 1993 alleging, without any evidence, that Jean-Bertrand Aristide, the man the administration was trying to restore as president of Haiti, was mentally unstabl e.

The Soviet Union, the CIA's main enemy, is gone. The crises in Bosnia and Somalia show there is no support in the United States for the use of the armed forces overseas. However, in the pullulating mini-crises around the world - from Chechnya to Macedonia - the CIA can make the case that it is the arm of the American government best equipped to defend its interests in places where it cannot bring its full military strength to bear.

THE SHORT, MESSY HISTORY OF THE CIA n1947 The Central Intelligence Agency is created by President Truman out of the wartime Office of Strategic Services; intended to ensure that the United States would never again be caught unawares as it had been at Pearl Harbor.

1953 Helped to restore the Shah of Iran to power.

1961 Sponsored the calamitous invasion of Cuba at the Bay of Pigs

1973 Covertly supported the overthrow of Salvador Allende, socialist president of Chile.

1973-74 Carried out illegal operations connected to the Watergate affair.

1975 Committee chaired by Vice President Nelson Rockefeller described how the agency had spied illegally on thousands of Americans opposed to the Vietnam war.

1985 Former CIA officer Edward Lee Howard accused of selling secrets to KGB agents in Austria.

n1986 Iran-Contra - illegal sale of arms to Iran was found to be linked to the CIA's secret support of Nicaraguan rebels.

1989-91 After years of over-estimating Soviet strength, the agency failed to predict the fall of the Berlin Wall, the collapse of the Soviet Union and the fall of Gorbachev.

1993 Having produced reports denouncing Jean-Bertrand Aristide, Haiti's exiled President, as mentally unbalanced, the agency was found to be using members of Haiti's military regime as informers.

1994 February: Aldrich H. Ames is uncovered as a spy after nine years working for the Soviets and Russians. Despite buying an expensive house, a red Jaguar and failing a polygraph test he had remained undetected.

1994 28 December: 23 months into the job, James Woolsey resigns as director of the CIA after Congressional criticism of his handling of the Ames case.