Some Benghazi residents even say that the militia seen carrying out the attack, Ansar al-Shariah, did a better job than the paralytic government at providing security and even some social services. “They are very nice people,” said Ashraf Bujwary, 40, an administrator at a hospital where Ansar al-Shariah men had served as guards. Security has been “on shaky ground” since the militia fled, he said.

In some ways Ansar al-Shariah exemplifies the twilight world of post-Qaddafi Libya, in which residents with looted weapons have organized themselves into regional, tribal or Islamist brigades to keep the peace and defend differing visions of Libya. In Bani Walid, near Misurata, the dominant militia is made up of former Qaddafi loyalists who have embraced a local strongman and rejected the new government. Some brigades provide public security or services; others oppose democracy as contrary to Islam. Ansar al-Shariah did both.

In a Congressional hearing last week, Eric A. Nordstrom, the former chief of security at the American Embassy in Libya, said that he had tracked Ansar al-Shariah as a potential threat “for quite some time.” He characterized the brigade as both “extremist” and, in his view, an informal arm of the Libyan government.

Wissam Bin Hamid, the 35-year-old leader of a major Benghazi militia, Libya Shield, said he considered Ansar al-Shariah more of an Islamic “social club” than a fighting brigade. “Families come to them when they have a problem with a son,” he said, like drug use or bad behavior. Like other Benghazi militia leaders, he said he wanted to see evidence before blaming Ansar al-Shariah for the attack.

Organizers of the march against the militias nonetheless insisted they had achieved at least a subtle change. The big turnout showed that supporters of a civilian government were in fact “the force on the ground,” insisted Abu Janash Mohamed Abu Janash, 26, one of the organizers.

But he also acknowledged that Ansar al-Shariah was not chased from its headquarters, as had been reported. He said the protest organizers had given Ansar al-Shariah a warning to evacuate. “They were friendly,” Mr. Abu Janash said. “We had lunch together.”

Only after the fact did Mr. Abu Janash learn that armed men had led the march several miles away to attack a larger militia known for defending the government. “The march was hijacked,” said Mr. Salabi, the brigade leader, who was wounded in the attack.