TRIPOLI/DERNA, Libya (Reuters) - Libya's army on Sunday ordered rogue armed groups in and around Tripoli to leave state and military premises or be ejected by force, apparently seeking to capitalize on the withdrawal of militias from Benghazi and Derna.
The two main Islamist militias in Derna, a town in eastern Libya known as an Islamist stronghold, said on Saturday they were disbanding after one of them, Ansar al-Sharia, was driven out of Libya's second city, Benghazi.
The many militias that still control the streets more than a year after rebels toppled Muammar Gaddafi are the clearest challenge to the authority of a central government forced to co-opt many of them to provide security.
However, the killing of four Americans including the ambassador in an attack on the U.S. consulate in Benghazi on September 11 seems to have given the nascent democratic administration a cue to rally support and channel public frustration with the militias.
Some U.S. officials have accused the Islamist Ansar al-Sharia of involvement in the attack, a charge it denies.
Ansar al-Sharia, opposed to democracy, is one of the groups that have operated outside the nominal Defense Ministry umbrella that covers ex-rebels approved - and needed - by the government.
"The army chief Yussef al-Mangoush and (national assembly leader) Mohammed Magarief have ordered all illegitimate militias should be removed from compounds and hand over their weapons to the national army," said Adel Othman al-Barasi, a spokesman for the Defense Ministry.
"A committee made up by the military police has been formed to take over the compounds and the weapons and hand these over to the army."
Similar edicts have come and gone in the past, with little or no effect on the militias, but the growing frustration of the public may be tipping the balance at street level.
In Derna, a man in a forklift truck came to the base vacated by the town's Abu Slim Martyrs brigade and drove away with a giant 105 mm rocket launcher to take it to a scrap yard.
Many people have resented Derna's reputation as a jihadi recruitment centre. Slogans painted on the wall of a school in English read: "Yes to pluralism! No to Qaeda! No to extremism!"
Barasi said the army had already evicted a militia from a base on the highway leading to Tripoli airport on Sunday, and all such handovers had been done peacefully.
A member of the army's National Mobile Force said it had been clearing rogue militias out of the western Tripoli district of Sarraj for days and on Sunday seized a tank and heavy and light weapons in evicting one from a military base.
"They tried to stop us but we managed to convince them to leave," he said, declining to be named. "We have taken control of 11 locations in Sarraj."
In a second operation later on Sunday, members of an armed group which had settled into a couple of western Tripoli villas, once home to foreign workers, were evicted, he said.
Slim Derby, leader of the Abu Slim Martyrs brigade, which is based in Derna, said "civil society groups came to our camps, and the youth demonstrators asked us to evacuate the place and disband".
"Our members have their own normal lives, so everyone will go back to their normal lives and their regular jobs."
Ansar al-Sharia made a similar announcement in Derna after protesters forced its Benghazi brigade out of its bases in that city on Friday.
Those invasions, which followed a mass demonstration in support of democracy and against Islamist militias, met little resistance and appeared to be part of a sweep of militia bases by police, army and activists.
Siraj Shennib, a 29-year-old linguistics professor, said protesters had been maintaining a vigil against the militias in Derna for 10 days, and the protests became much larger after a car-jacking three days ago.
Lieutenant-Colonel Mohamed Ali Qasim, a military police officer in sandals and civilian clothes, arrived with a group of soldiers to inspect the base vacated by the Abu Slim Martyrs.
"Yesterday the people and the crowd and civil society groups came here and peacefully took over the place," he said.
"The people of Derna are peaceful ... There may be some who are hot blooded, but they are not extremists ... They suffered a lot under Gaddafi: they were treated violently."
However, at another, much larger Abu Slim camp on the outskirts, there was no sign of weapons but a group of about 10 unarmed fighters confronted a Reuters news crew at the gate and confiscated a photo memory card and two mobile phones.
"We are al Qaeda! We are al Qaeda!" one shouted.
"Get out of Derna!" shouted another.
Derna, set in green hills overlooking the Mediterranean, is known across the region as a recruitment centre for fighters who joined the wars in Iraq, Afghanistan and Syria.
Unlike most of the Libyan militias, which were formed for last year's civil war, the Derna groups, especially the Abu Slim Martyrs, are veteran guerrilla fighters with many years of history fighting Gaddafi in the hills of eastern Libya.
The group is named after the Tripoli prison where Gaddafi's jailers killed around 1,200 prisoners in 1996.
The head of Libya's national congress, Mohammed Magarief, met government and security officials in Benghazi late on Saturday and then announced the formation of a "security operations room".
He said this would bring together the army and interior ministry forces with Defense Ministry brigades made up of former rebels and work to secure Benghazi.
Besides saying he wanted to dissolve rogue militias, he said the government wanted the army to take over pro-government militias' compounds as a step towards integrating them into regular forces.
Other problems associated with the militias were dramatically illustrated on Friday when the protesters who had pushed Ansar al-Sharia out of Benghazi moved on to another compound believing that it, too, harbored an Islamist militia.
It turned out to be the base of the powerful pro-government Rafallah al-Sahati group, which opened fire in an attempt to protect a large weapons store it had been asked to guard.
Eleven people were killed and more than 60 injured before the militia pulled back and left the arsenal to be looted.
Nasser Abdelhaaq, a Rafallah al-Sahati commander, suggested the crowd had been manipulated to turn on his group, an officially approved militia that also has Islamist leanings.
Six of the dead were bodyguards of a colonel in the regular Libyan army who went missing on Friday, suggesting a kidnapping that may have been the work of a militia group.
Additional reporting by Omar al-Mosmary, Mohammed Al-Tommy in Benghazi and Ali Shuaib in Tripoli; Writing by Kevin Liffey; Editing by Sophie Hares