CAIRO — Ansar al-Shariah, the brigade of rebel fighters that witnesses say led the attack on the United States diplomatic mission in Benghazi, holds that democracy is incompatible with Islam. It has paraded the streets with weapons calling for an Islamic state, and a few months ago its leader boasted publicly that its fighters could flatten a foreign consulate.

But if the group’s ideology may put it on the fringe of Libyan society, its day-to-day presence in society does not. It is just one of many autonomous battalions of heavily armed men formed during and after the uprising against Col. Muammar el-Qaddafi who have filled the void in public security left by his fall, resisting calls to disarm by saying that the weak transitional government is not up to the job.

Ansar al-Shariah’s fighters have given conflicting stories about their role in the attack. Said to number fewer than 200, they can usually be found at Al Jala Hospital in Benghazi, where they act as its guards and protectors. And when instead they turned their guns on the United States mission, American security officers and the Libyan authorities did not call for help from any formal military or police force — there is none to speak of — but turned to the leader of another autonomous militia with its own Islamist ties.

“We had to coordinate everything,” said that militia leader, Fawzi Bukatef, recalling the first phone call about the attack that he received from the mission’s security team. The Libyan government, he said, “was absent.”