Read a version of this story in Arabic
Benghazi, Libya (CNN) -- Two Islamist militias have agreed to close their bases in the eastern Libyan city of Derna, state news and a source said Saturday.
A third base will be shut on Sunday, said the source, who spoke on the condition of anonymity.
The state-run LANA news agency said the militias, which it identified as Bou Salim Martyrs and Ansar al-Sharia, will also disband.
The move comes after hundreds marched in the nearby city of Benghazi and took over the headquarters for Ansar al-Sharia. Individuals from the radical Islamist group are accused of having been involved in the attack last week that left four Americans dead.
Protesters demanded an end to all security activities of armed groups operating outside the official command of the army or police.
Mohamed al-Magariaf, president of Libya's General National Congress, later told reporters that a joint security office would be established to bring together the army and the various brigades backed by the government. Militias outside that office will not be allowed to operate, he said.
As militia members fled the headquarters in Benghazi, demonstrators torched a vehicle and took over the group's building without firing a single shot.
Army General Naji al-Shuaibi said the citizens, whom he referred to as "revolutionaries of the February 17 uprising," later asked that the Ansar al-Sharia headquarters be handed over to the Libyan army.
Some protesters also gathered at locations that house forces loyal to the national authority, he said, including the headquarters of the Rufallah al-Sihati battalion. Gunfire could be heard there, but it was not clear who was responsible.
At least four people were killed and 70 were injured in clashes at the Rufallah al-Sihati brigade headquarters, LANA reported.
Al-Magariaf thanked the protesters for helping evict "armed groups." He also said the Rufallah al-Sihati brigade was actually "under the command of -- and committed to -- the national authority," the case appeared to be one of mistaken identity. Magariaf asked demonstrators to stop their activities and go home.
On the night of September 11, U.S. Ambassador Chris Stevens was one of four Americans slain after a group assaulted the U.S. Consulate in the eastern Libyan city.
Seen as the birthplace of the revolution that led to the death of longtime Libyan leader Moammar Gadhafi, Benghazi has in recent months been beset by security issues.
Initial reports indicated that, ahead of the consular attack, Ansar al-Sharia had organized a protest to decry an inflammatory film that mocks the Prophet Mohammed and also protest the United States, where the film was privately produced.
On Thursday, Libyan Prime Minister Mustafa Abushagur said eight detained in connection with that assault include members of Ansar al-Sharia, though he added that not all the attackers came from one specific group.