Among the more than two dozen American personnel evacuated from the city after the assault on the American mission and a nearby annex were about a dozen C.I.A. operatives and contractors, who played a crucial role in conducting surveillance and collecting information on an array of armed militant groups in and around the city.
“It’s a catastrophic intelligence loss,” said one American official who has served in Libya and who spoke on the condition of anonymity because the F.B.I. is still investigating the attack. “We got our eyes poked out.”
The C.I.A.’s surveillance targets in Benghazi and eastern Libya include Ansar al-Sharia, a militia that some have blamed for the attack, as well as suspected members of Al Qaeda’s affiliate in North Africa, known as Al Qaeda in the Islamic Maghreb.
Eastern Libya is also being buffeted by strong crosscurrents that intelligence operatives are trying to monitor closely. The killing of Mr. Stevens has ignited public anger against the militias, underscored on Friday when thousands of Libyans took to the streets of Benghazi to demand that the groups be disarmed. The makeup of militias varies widely; some are moderate, while others are ultraconservative Islamists known as Salafis.
“The region’s deeply entrenched Salafi community is undergoing significant upheaval, with debate raging between a current that is amenable to political integration and a more militant strand that opposes democracy,” Frederic Wehrey, a senior policy analyst with the Carnegie Endowment for International Peace who closely follows Libya and visited there recently, wrote in a paper this month, “The Struggle for Security in Eastern Libya.”
American intelligence operatives also assisted State Department contractors and Libyan officials in tracking shoulder-fired missiles taken from the former arsenals of the former Libyan Col. Muammar el-Qaddafi’s forces; they aided in efforts to secure Libya’s chemical weapons stockpiles; and they helped train Libya’s new intelligence service, officials said.
Senior American officials acknowledged the intelligence setback, but insisted that information was still being collected using a variety of informants on the ground, systems that intercept electronic communications like cellphone conversations and satellite imagery. “The U.S. isn’t close to being blind in Benghazi and eastern Libya,” said an American official.
Spokesmen for the C.I.A., the State Department and the White House declined to comment on the matter on Sunday.
Within months of the start of Libyan revolution in February 2011, the C.I.A. began building a meaningful but covert presence in Benghazi, a locus of the rebel efforts to oust the government of Colonel Qaddafi.
Though the agency has been cooperating with the new post-Qaddafi Libyan intelligence service, the size of the C.I.A.’s presence in Benghazi apparently surprised some Libyan leaders. The deputy prime minister, Mustafa Abushagour, was quoted in The Wall Street Journal last week saying that he learned about some of the delicate American operations in Benghazi only after the attack on the mission, in large part because a surprisingly large number of Americans showed up at the Benghazi airport to be evacuated.
“We have no problem with intelligence sharing or gathering, but our sovereignty is also key,” said Mr. Abushagour.
The attack has raised questions about the adequacy of security preparations at the two American compounds in Benghazi: the American mission, the main diplomatic facility where Mr. Stevens and another American diplomat died of smoke inhalation after an initial attack, and an annex a half-mile away that encompassed four buildings inside a low-walled compound.
From among these buildings, the C.I.A. personnel carried out their secret missions. The New York Times agreed to withhold locations and details of these operations at the request of Obama administration officials, who said that disclosing such information could jeopardize future sensitive government activities and put at risk American personnel working in dangerous settings.
In Benghazi, both compounds were temporary homes in a volatile city teeming with militants, and they were never intended to become permanent diplomatic missions with appropriate security features built into them.
Neither was heavily guarded, and the annex was never intended to be a “safe house,” as initial accounts suggested. Two of the mission’s guards — Tyrone S. Woods and Glen A. Doherty, former members of the Navy SEALs — were killed just outside the villa’s front gate. A mortar round struck the roof of the building where the Americans had scrambled for cover.