Troops deployed in Tripoli on Monday after militias were ordered to leave the capital following deadly weekend clashes sparked by a protest against the former rebels in Libya's 2011 revolt.
The unrest was the deadliest in the capital since the uprising and erupted when former rebels from Misrata fired on protesters, triggering clashes that killed 43 people and wounded 450.
Growing lawlessness plaguing Libya since the uprising was further compounded when gunmen on Sunday abducted the deputy head of intelligence services, Mustafa Nuh, near Tripoli airport.
Nuh was released on Monday and later told private television channel Al-Naba that his captors took him to the western city of Zintan.
He did not elaborate on the motives for the kidnapping.
Ex-rebels from Zintan, like those from Misrata, control parts of Tripoli.
Former rebels helped topple and kill veteran dictator Moamer Kadhafi in 2011, but have since banded into militias carving their own fiefdoms, each with its own ideology and regional allegiance.
The Zintan and Misrata former insurgents are the most heavily armed groups to have emerged from the uprising, having looted Kadhafi's arsenal, seizing light and heavy weapons, armed vehicles and even tanks.
The abduction of Nuh, who is originally from Misrata, came as Tripoli on Sunday observed the first of three days of a strike called by the city council to mourn the victims of the latest violence.
Misrata community leaders, officials and former rebel commanders urged the "withdrawal of all ex-rebels from the city of Misrata who are in Tripoli... in under 72 hours," in a statement Sunday.
The militiamen began withdrawing Monday as dozens of soldiers and armoured vehicles deployed in Tripoli.
"A number of units of the national army are about to enter the city of Tripoli from several areas in order to secure it," the government said in a statement.
Soldiers aboard armoured vehicles were seen making their way into the city centre from the east, making victory signs at passing drivers who sounded their horns in approval.
Signup to our newsletter and follow us on Facebook and Twitter!
Heroes turned villains
The Misrata brigade at the heart of the latest violence saw some of the heaviest fighting during the uprising against Kadhafi, when Misrata was besieged by regime forces.
But many such groups have rejected government calls to lay down their arms or integrate into the armed forces, triggering the frustration of Libyans who once hailed them as heroes for toppling Kadhafi.
Demonstrators protesting against militias on Friday in Tripoli's Gharghour neighbourhood were fired upon from villas occupied by the Misrata fighters, who killed several protesters before rival militiamen swept in, sparking clashes that continued until Saturday.
In response to the bloodshed, Tripoli city council called the three-day general strike, and on Monday many shops and businesses remained closed, an AFP journalist said.
Universities in the city announced on Monday they would close for the week.
Hanan Salah, a Human Rights Watch researcher, said the latest clashes "showcase the extent of the reckless acts of unaccountable militias these past two years, and the government's lack of ability to control them".
Even as calm returned to Tripoli, violence erupted in the restive east and its capital Benghazi where military governor Colonel Abdallah al-Saati escaped a bomb blast on Monday.
But one member of his entourage was killed and another seriously wounded in the attack, the latest in a wave of deadly violence targeting security personnel and other officials.
Bombings and shootings in the region have killed more than 100 army and police officers and judges since the end of the uprising.
Violence has also rocked western Libya in the past week.
Late Sunday, gunmen stormed the office of council official Yussef al-Atrash, a former rebel commander, and shot him dead in the western town of Al-Ajilat, Libyan news agency LANA said.
The violence has also taken its toll on journalists, and on Monday press watchdog Reporters Without Borders said a local photographer had been killed in the Tripoli violence and others hurt.