A Libyan soldier at a military compound in Tripoli checks weapons turned in by rebel fighters and civilians. The weak Libyan government must try to bring militias to heel while depending on them as the only armed forces, a conundrum trapping the nation in a state of lawlessness.

BENGHAZI, libya —A month after the killing of the U.S. ambassador ignited a public outcry for civilian control of Libya’s fractious militias, that hope has been all but lost in a tangle of grudges, rivalries and egos.

Scores of disparate militias remain Libya’s only effective police force but have stubbornly resisted government control, a dynamic that is making it difficult for either the Libyan authorities or the United States to catch the attackers who killed Ambassador Chris Stevens.

Shocked by that assault, tens of thousands of people filled the streets last month to demand the dismantling of the militias. But the country’s interim president, Mohamed Magariaf, warned them to back off as leaders of the largest brigades threatened to cut off the vital services they provide, such as patrolling the borders and putting out fires.

“We feel hurt; we feel underappreciated,” said Ismail el-Salabi, one of several brigade leaders who warned that public security had deteriorated because their forces had pulled back.

Taming the militias has been the threshold test of Libya’s attempt to build a democracy after four decades of dictatorship under Moammar Khadafy. But how to bring them to heel while depending on them for security has eluded the weak transitional government, trapping Libya in a state of lawlessness.

Now, that problem has become entangled in the U.S. presidential race as well, with Republicans arguing that the Obama administration’s failure to protect Stevens illustrates the unraveling of its policy in the region. Mounting pressure on the administration to act against the perpetrators carries its own risks: A U.S. strike on Libyan soil could produce a popular and potentially violent backlash in the only Arab country whose people largely have warm feelings toward Washington.

The militias’ power is evident. In one of Tripoli’s finest hotels, the Waddan, about two dozen militiamen from the western city of Misrata continue to help themselves to rooms without paying, just as they have for more than a year. The interim interior minister, also from Misrata, protects them.

In Benghazi, independent brigades are using tapped telephones to hunt down suspected loyalists of Khadafy, with the help of his former intelligence services. Even the huge anti-militia protest last month became cover for a group of armed men to attack one of the largest brigades, possibly for revenge.

“Nothing changes,” said Fathi al-Obeidi, the militia commander who led a contingent of fighters that helped rescue the Americans in the besieged diplomatic mission last month.

Some Benghazi residents 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-Khadafy 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 Misrata, the dominant militia is made up of former Khadafy loyalists who have embraced a local strongman and rejected the new government. Some brigades provide public security or services, while others oppose democracy as contrary to Islam. Ansar al-Shariah did both.

In a congressional hearing last week, Eric Nordstrom, former chief of security at the U.S. Embassy in Libya, said he had tracked Ansar al-Shariah as a potential threat “for quite some time.” He characterized the brigade as “extremist” and 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” such as drug use or bad behavior, he said. 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.

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,” Abu Janash said. “We had lunch together.”

Only after the fact did Abu Janash learn armed men had led the march several miles away to attack a larger militia known for defending the government.

“The march was hijacked,” said el-Salabi, the brigade leader, who was wounded in the attack.

The civilian government responded to the outcry by assigning military officers to help oversee the biggest militias. But the brigade leaders said that they, not the government, would choose their new officers, and that the current commanders would not yet give up control. The militia leaders say they refuse to submit to the national army or the police because so many of the officers used to work for Khadafy.

“You have militia commanders who love the prestige, who have more power than they could ever imagine,” said Zeidoun bin Hamid, the director of operations for Libya Shield.

More in News

The Denver Art Museum plans to funnel a $25 million one-time gift into the estimated $150 million budget for renovating its iconic North Building in time for the structure’s 50th anniversary in 2021, officials announced Thursday.

President-elect Donald Trump is expected to name fast-food executive Andrew Puzder, a vocal critic of substantially increasing the minimum wage and an opponent of rules that would make more workers eligible for overtime pay, as head of the Labor Department.