BENGHAZI, Libya — Galvanized by anger over the killing of the popular American ambassador here last week, thousands of Libyans marched through this city on Friday, demanding the disarming of the militias that helped topple the dictatorship but have troubled the country with their refusal to disband.

In a show of mass frustration at the armed groups, protesters seized control of several militia headquarters on Friday night and handed them over to Libya’s national army in what appeared to be a coordinated sweep. They also stormed the headquarters of Ansar al-Shariah, a hard-line Islamist militia that has been linked to the attack on the United States Mission in Benghazi that killed the ambassador and three other Americans.

As members of Ansar al-Shariah fled their headquarters, protesters set at least one vehicle on fire, and Reuters reported that one person was killed. There were unconfirmed reports that several had been wounded by the departing gunmen.

At the seized headquarters of another militia, protesters burned and pillaged a large number of weapons, and hundreds of looters could be seen walking away with automatic rifles and rocket-propelled grenade launchers.