Hezbollah's longtime leader, Sheik Hassan Nasrallah, boasted on television in June that he had rooted out at least two CIA spies who had infiltrated the ranks of Hezbollah, which the U.S. considers a terrorist group closely allied with Iran. Though the U.S. Embassy in Lebanon officially denied the accusation, current and former officials concede that it happened and the damage has spread even further.
In recent months, CIA officials have secretly been scrambling to protect their remaining spies - foreign assets or agents working for the agency - before Hezbollah can find them.
To be sure, some deaths are to be expected in shadowy spy wars. It's an extremely risky business and people get killed. But the damage to the agency's spy network in Lebanon has been greater than usual, several former and current U.S. officials said, speaking on condition of anonymity because they were not authorized to speak publicly about security matters.
The Lebanon crisis is the latest mishap involving CIA counterintelligence, the undermining or manipulating of the enemy's ability to gather information. Former CIA officials have said that once-essential skill has been eroded as the agency shifted from outmaneuvering rival spy agencies to fighting terrorists. In the rush for immediate results, former officers say, tradecraft has suffered.
The most recent high-profile example was the suicide bomber who posed as an informant and killed seven CIA employees and wounded six others in Khost, Afghanistan in December 2009.
Last year, then-CIA director Leon Panetta said the agency had to maintain "a greater awareness of counterintelligence." But eight months later, Nasrallah let the world know he had bested the CIA, demonstrating that the agency still struggles with this critical aspect of spying and sending a message to those who would betray Hezbollah.
The CIA was well aware the spies were vulnerable in Lebanon. CIA officials were warned, including the chief of the unit that supervises Hezbollah operations from CIA headquarters in Langley, Va., and the head of counterintelligence. It remains unclear whether anyone has been or will be held accountable in the wake of this counterintelligence disaster or whether the incident will affect the CIA's ability to recruit assets in Lebanon.
In response to AP's questions about what happened in Lebanon, a U.S. official said Hezbollah is recognized as a complicated enemy responsible for killing more Americans than any other terrorist group before September 2001. The agency does not underestimate the organization, the official said.
The CIA's toughest adversaries, like Hezbollah and Iran, have for years been improving their ability to hunt spies, relying on patience and guile to exploit counterintelligence holes.
In 2007, for instance, when Ali-Reza Asgari, a brigadier general in the Islamic Revolutionary Guards Corps of Iran, disappeared in Turkey, it was assumed that he was either killed or defected. In response, the Iranian government began a painstaking review of foreign travel by its citizens, particularly to places like Turkey where Iranians don't need a visa and could meet with foreign intelligence services.
It didn't take long, a Western intelligence official told the AP, before the U.S., Britain and Israel began losing contact with some of their Iranian spies.
The State Department last year described Hezbollah as "the most technically capable terrorist group in the world," and the Defense Department estimates it receives between $100 million and $200 million per year in funding from Iran.
Backed by Iran, Hezbollah has built a professional counterintelligence apparatus that Nasrallah - whom the U.S. government designated an international terrorist a decade ago - proudly describes as the "spy combat unit." U.S. intelligence officials believe the unit, which is considered formidable and ruthless, went operational in about 2004.
Using the latest commercial software, Nasrallah's spy-hunters unit began methodically searching for spies in Hezbollah's midst. To find them, U.S. officials said, Hezbollah examined cellphone data looking for anomalies. The analysis identified cellphones that, for instance, were used rarely or always from specific locations and only for a short period of time. Then it came down to old-fashioned, shoe-leather detective work: Who in that area had information that might be worth selling to the enemy?
The effort took years but eventually Hezbollah, and later the Lebanese government, began making arrests. By one estimate, 100 Israeli assets were apprehended as the news made headlines across the region in 2009. Some of those suspected Israeli spies worked for telecommunications companies and served in the military.
Back at CIA headquarters, the arrests alarmed senior officials. The agency prepared a study on its own vulnerabilities, U.S. officials said, and the results proved to be prescient.
The analysis concluded that the CIA was susceptible to the same analysis that had compromised the Israelis, the officials said.
CIA managers were instructed to be extra careful about handling sources in Lebanon. A U.S. official said recommendations were issued to counter the potential problem.
But it's unclear what preventive measures were taken by the Hezbollah unit chief or the officer in charge of the Beirut station. Former officials say the Hezbollah unit chief is no stranger to the necessity of counterintelligence and knew the risks. The unit chief has worked overseas in hostile environments like Afghanistan and played an important role in the capture of a top terrorist while stationed in the Persian Gulf region after the attacks of 9/11.
"We've lost a lot of people in Beirut over the years, so everyone should know the drill," said a former Middle East case officer familiar with the situation.
But whatever actions the CIA took, they were not enough. Like the Israelis, bad tradecraft doomed these CIA assets and the agency ultimately failed to protect them, an official said. In some instances, CIA officers fell into predictable patterns when meeting their sources, the official said.
This allowed Hezbollah to identify assets and case officers and unravel at least part of the CIA's spy network in Lebanon. There was also a reluctance to share cases and some files were put in "restricted handling." The designation severely limits the number of people who know the identity of the source but also reduces the number of experts who could spot problems that might lead to their discovery, officials said.
Nasrallah's televised announcement in June was followed by finger-pointing among departments inside the CIA as the spy agency tried figure out what went wrong and contain the damage.
The fate of these CIA assets is unknown. Hezbollah treats spies differently, said Matthew Levitt, a counterterrorism and intelligence expert at the Washington Institute for Near East Studies who's writing a book about the terrorist organization.
"It all depends on who these guys were and what they have to say," Levitt said. "Hezbollah has disappeared people before. Others they have kept around."
Who's responsible for the mess in Lebanon? It's not clear. The chief of Hezbollah operations at CIA headquarters continues to run the unit that also focuses on Iranians and Palestinians. The CIA's top counterintelligence officer, who was one of the most senior women in the clandestine service, recently retired after approximately five years in the job. She is credited with some important cases, including the recent arrests of Russian spies who had been living in the U.S. for years.
Officials said the woman was succeeded by a more experienced operations officer. That officer has held important posts in Moscow, Southeast Asia, Europe and the Balkans, important frontlines of the agency's spy wars with foreign intelligence services and terrorist organizations.