The attack on the US consulate in Benghazi certainly revealed some level of instability in Libya. It showed the consequences of military intervention, putting guns into a country and inevitably seeing them funnel into the hands of extremists. And there is justifiable criticism of the new Libyan government as ineffective outside a very narrow band.

And yet, we should not see Libya or its people as monolithic. For every militia group, there are hundreds of thousands if not millions of newly empowered citizens, who in heartening fashion <drove Islamists out of their bases in Benghazi and Derna over the weekend:

The two main Islamist militias in Derna, a city in eastern Libya known as an Islamist stronghold, withdrew from their five bases on Saturday and announced they were disbanding, residents said, a day after a militia was driven out of Benghazi.

The Abu Slim and Ansar al-Sharia militias’ announcements were apparently motivated by events in Benghazi, where Ansar al-Sharia, a group linked with last week’s deadly attack on the U.S. consulate, withdrew from all its bases in the city late on Friday amid mass demonstrations in support of the government.

Those demonstrations in Libya’s second city, also in the east, erupted into violence when the crowd turned against another group that had sworn support for the government.

“The militia in Derna saw what happened last night and they decided: we will not kill our brothers. So they disbanded,” Siraj Shennib, a 29-year-old linguistics professor who had been part of protests against the militia, said by telephone.

This resulted from protests to take back the streets, which ended up with 14 dead and 70 wounded, but which succeeded in moving out the militia groups. The Libyan government vowed to disarm the militias, but that carries less weight than the actions of the public. The protests enabled the state military to take over those militia bases.

We’re seeing a very cockeyed, occasionally violent version of democracy in action here. The public wants the state military to provide security, and seeks an end to fears from the Salafist militia attacks, which have grown in recent weeks. They took matters into their own hands, and in so doing gave the government the mandate it needed to make changes.

In perhaps better news for the stability of Libya, the attack on US Ambassador Christopher Stevens and the US consulate led to the removal of a vast CIA network in the country.

Among the more than two dozen American personnel evacuated from the city after the assault on the American mission and a nearby annex were about a dozen C.I.A. operatives and contractors, who played a crucial role in conducting surveillance and collecting information on an array of armed militant groups in and around the city.

“It’s a catastrophic intelligence loss,” said one American official who has served in Libya and who spoke on the condition of anonymity because the F.B.I. is still investigating the attack. “We got our eyes poked out.”

I would say that the death of the US Ambassador is the catastrophic loss here. The loss of CIA personnel doesn’t rise to that level. In fact, it may – perish the thought – leave the responsibility for Libya to its people, who have begun to take up that burden. It’s definitely unclear how that will turn out, but I think it has a much better chance without the spooks involved.