The Libyan army ejected a rogue militia from its headquarters on Sunday, the first move in a government-threatened crackdown on such groups.

Libyan soldiers man a checkpoint in Benghazi on Sunday. European Pressphoto Agency

Libya's new government appears intent on capitalizing on the popular backlash that erupted locally in the wake of the killing of the American ambassador this month.

Militias that have held sway in much of Libya since the revolution that toppled Moammar Gadhafi last October appear to have rapidly retreated in recent days amid mass demonstrations that appear to have emboldened the government to take action.

Libya's state news agency reported on Sunday that the army had peacefully evicted one militia from an army building near Tripoli's airport hours after issuing a 48-hour ultimatum for rogue militias to give up state and military premises and turn over weapons. The army pledged it would use force against any groups that refused to heed the ultimatum, the state news agency reported.

On Friday, thousands of demonstrators in Benghazi stormed the compound of the militant Islamist group Ansar al-Sharia and set it on fire.

Ansar has become a primary target in the search for those responsible for the Sept. 11 attack on the U.S. consulate in Benghazi, in which four Americans, including Ambassador Christopher Stevens, died. U.S. and Libyan officials said some of the group's members were in communication with al Qaeda ahead of the battle. The group has repeatedly denied it was responsible for organizing or directing the attack on the consulate.

But underscoring the confusion surrounding militias, protesters then lay siege to the headquarters of another militia, the Rafallah Sahati brigade, apparently unaware that it was approved by the Ministry of Defense and tasked with guarding a sizable weapons storehouse in the city. Eleven people died in the ensuing clashes.

On Saturday, the two largest Islamist militias in another eastern Libyan city, Darna, said they intended to disband and turn over their weapons to the government. Darna is significant because it has long been known as a hotbed of Islamic militancy.

Libyan officials said they are hopeful that their government has turned a corner in the struggle to rein in militias and assert control over the whole country. But many ordinary Libyans remain skeptical that powerful militias, many of which have vast weapons arsenals, will surrender so easily and may simply be beating a tactical retreat until popular anger calms.

"Some of these groups are sincerely committed to doing what's best for the country, but others—no way they'll just surrender because someone in Tripoli orders them to," said Benghazi resident Jamal el-Kour.

Since the end of the revolution last year, Libya's security establishment has been divided on how to deal with the scores of militias, composed predominantly of ex-rebels who fought to topple the Gadhafi regime.

Many local militias have been brought nominally under the government's command, providing security in places where the weak central government is unable to do so.

But other rogue militias have rebuffed invitations to work within the government umbrella. Some government officials have privately recommended that the national forces use force to disband the holdouts, citing the escalating threat of allowing these groups to remain armed and unanswerable to central authority.

However, several leading members of the transitional parliament, known as the National Transitional Council, refused to approve any armed response against the militants because of their fear of sparking an internecine war.

Mustafa Abushagour, who Congress nominated on Sept. 13 to be Libya's next prime minister and is in the process of forming a new government, told The Wall Street Journal on Thursday that he considered radical Islamist militias to be among the country's greatest national security threats, but said he would support a cautious approach to handling the issue.

He said he wasn't convinced that attacking groups like Ansar al-Sharia with force was the most effective way to stamp out their threat.

"We take [this threat] very seriously, but we have to have serious programs about how to handle it," Mr. Abushagour said. "These groups are a small segment of society. They grow in an oppressive environment.…And we don't want to mimic the [oppressive Gadhafi-era environment] in which they were created."

Write to Charles Levinson at and Margaret Coker at