Adding to the feeling of lawlessness are the revelations that foreign intelligence services, like the C.I.A., are active around the country without answering to anyone, people here said. Every day, an American drone circles Benghazi, unsettling and annoying residents. Police officers share Kalashnikovs. The courts are toothless. Libyan and American investigators, faced with Benghazi’s insecurity, are forced to interview witnesses hundreds of miles away, in the capital, Tripoli.

And so the government is forced to reckon with the militias, who by virtue of their abundant weapons hold the city’s real power. Men like Wissam bin Hamid, 35, who before the revolution owned an automobile workshop, is now the leader of an umbrella group of former rebel fighters. Some groups, like Mr. Hamid’s, operate with the government’s blessing, while others are called rogue. The distinctions often seem arbitrary, but either way, the militias are effectively a law unto themselves.

Mr. Hamid and others insist that they are loyal to the state. Leading political figures said they respected Mr. Hamid but had concerns about many of the other militia leaders, among them hard-line Islamists.

The militias are called on for crucial tasks, including safeguarding elections. Mr. Hamid’s militia, a branch of a group called Libya Shield, has been called on to enforce order hundreds of miles away from Benghazi, in towns beyond the government’s reach. The militia has also worked with American officials: they escorted intelligence officers and diplomats away from the besieged villas on Sept. 11, and later, provided protection for American investigators visiting the city in search of evidence in the attack, Mr. Hamid said.

Ultimately, it could fall to Mr. Hamid and his men to confront commanders of Ansar al-Shariah, the hard-line Islamist militia that Libyan and American officials have linked to the attack, since no other government agencies seem capable of the task.

But Mr. Hamid said he would not — because he believes the militia’s leaders are innocent, but also because in Benghazi, the ties between former rebel fighters run deep. “They were with us on the front lines,” he said.

Ansar al-Shariah’s leaders have strongly denied any involvement in the attack. Mr. Hamid insisted he would act against the group, if given proof it was responsible.