Militia groups from the Libyan city of Misrata have been ordered to leave the capital, Tripoli, within three days following deadly clashes there.
Tripoli is now observing a three-day strike in protest at Misrata gunmen who opened fire on demonstrators trying to evict them from their headquarters.
Libya's deputy intelligence chief was abducted on Sunday but has since been freed, military sources told the BBC.
Two years after its revolution, Libya still lacks a stable government.
The rival militias which helped topple Col Muammar Gaddafi in 2011 have so far refused to disarm.
No group has said it abducted the deputy head of the intelligence agency, Mustafa Nuh, but militias have seized senior officials before to get political leverage.
Mr Nuh was bundled into a car after arriving at Tripoli international airport on Sunday, but military sources told the BBC he was later released.
He was kidnapped with former rebel commander Alaa al-Hafs, who managed to escape, reports the BBC's Rana Jawad from Tripoli.
Mr Hafs told the BBC Mr Nuh had been taken captive by men from the western town of Zintan who had beaten him up.
Mr Nuh was freed following the intervention of the Shura Council of Zintan, made up of local elders, he said.
Zintan has the most powerful brigades in Tripoli and some of them are loosely attached to the defence ministry, our correspondent says.
Most of their bases are on the road leading to the airport, she adds.
Prime Minister Ali Zeidan was held hostage for several hours by gunmen in October, before being released unharmed.
At least 43 people were killed on Friday and Saturday when Misrata gunmen opened fire on protesters who were demanding they leave Tripoli.
In a joint statement on Sunday, Misrata's local council and the council of elders said all militia groups from the city - without exception - must pull out of Tripoli within 72 hours.
The statement said Libya's national congress and government were responsible for securing Tripoli.
Shortly afterwards, Khalil al-Ruwaiti, who heads a unit under the Misrata Shield brigade, confirmed to the BBC that his fighters would leave the capital.
The Misrata Shield brigade is nominally attached to the ministry of defence, but - like other Shield groups - is viewed by people as having a semi-official status that can operate independently when it chooses to, the BBC's Rana Jawad in Tripoli reports.
The brigade is not part of the militias which clashed with the protesters on Friday.
Emotions have been running high in Tripoli after the clashes, and Misrata's statement will be seen as a positive development, our correspondent says.
Dozens of protesters broke into the Libyan parliament on Sunday to demand action on keeping the militias out of Tripoli.
Libya's central government has struggled to keep control of militia groups from Misrata and other towns.
Tripoli remains tense and volatile. Most shops and schools are closed and many roadblocks have been erected by local residents and various armed groups.