Libya’s army chief of staff resigned on Sunday as an elite military unit took control of a base of pro-government militias after clashes killed 31 people in the eastern city of Benghazi.

The developments underlined the security chaos in Libya more than a year and a half after longtime dictator Moammar Gadhafi was deposed in a civil war.

The violence broke out Saturday when protesters stormed a base belonging to Libya Shield, a grouping of militias aligned with the military that were tasked with helping to maintain security. The protesters were demanding that the militias leave their camp and submit to the full authority of Libya’s security forces.

It remains unclear which side fired first. Libyan officials have provided few details of the clashes.

Witnesses said some of the protesters brought weapons to the camp, which was the main Benghazi base for Libya Shield militiamen. The militiamen appeared outnumbered by hundreds of protesters outside the gates.

Hospital officials said protesters made up most of the dead. Many were buried Sunday.

According to the director at the city’s Jalaa Hospital Mohamed Belied, the deaths were caused by gunshots and shrapnel. He said that dozens of people were wounded.

In one immediate result of the violence, Army Chief of Staff Maj. Gen. Youssef al-Mangoush resigned citing the unusually high death toll from the Benghazi clashes.

Military officers had been protesting against al-Mangoush for weeks, accusing him of corruption and of failing to exert authority over militias. Some militias were believed to have favored al-Mangoush remaining in his post, because he had been unable to replace them with a strong unified force.

Benghazi, the birthplace of the revolution that led to the ouster of Gadhafi, was the site of the Sept. 11 assault last year on the U.S. diplomatic mission that killed Ambassador Chris Stevens and three other Americans. High level police officials have also been assassinated and security bases have come under frequent attack there by unidentified assailants.

Militias have taken on greater roles since the fall of Gadhafi, providing border protection and security at airports to fill the vacuum as the central government has been unable to exert control.

The deadly clashes are likely to further inflame anger against militias, which have been accused of acting with impunity and enforcing their own agendas.

While some Libyans see the continued presence of militias as an obstacle to restoring security in the North African state, others believe they are playing a positive role in maintaining law and order while efforts to rebuild a professional army and a police force are underway.

Many residents of the city blame the country’s central government for failing to impose its authority on militias and clamp down on a proliferation of weapons from the 2011 civil war. Some have even pressed for self-rule, complaining about discrimination by the west, where the capital, Tripoli, is located.

Prime Minister Ali Zidan, in a statement issued early Sunday after he cut short a tour in Libya’s western towns, described the events as “sad and painful” and urged people to be cautious and exercise self-restraint.