Tripoli's residents awoke on Wednesday to a city in lockdown as security forces were deployed across the capital to clamp down on rogue militias.

After weeks of sporadic violence and night-time anarchy, the government is making a determined effort to rid the city of gunmen, giving militias two weeks to leave or disarm.

Side streets were blocked with trucks, rubble or piles of timber, and vehicles on main roads were searched for weapons.

The measures, set to continue for the rest of December, were announced by the prime minister, Abdurrahim el-Keib, in response to a series of shoot-outs in recent days.

"The people demand safety provided by legitimate government enforcement bodies, and it is our duty to respond," said Razzak Abuhajar, chairman of Tripoli council.

The government, whose cabinet were sworn in last weekend, has given militias until 20 December to come under state control, or face the consequences.

Tripoli's residents also have until the end of the year to turn in firearms in what the authorities hope will end the wild west image the city has been gaining.

"We have had complaints from the citizens," said the interior minister, Fawzi Abdel Aal. "We have a comprehensive plan to integrate all fighters who are willing to work with the interior ministry."

Some of the shootings are the result of clashes between Tripoli and out-of-town militias, and many residents complain that units loyal to Muammar Gaddafi continue to roam the streets.

Around the central Safari hotel, home to western journalists, gunmen backed by jeeps mounted with anti-aircraft guns were on Wednesday searching cars at a checkpoint yesterday. Side roads were blocked to prevent militiamen infiltrating the city centre.

"They are stealing and breaking stuff, we have to take control," said Ahmed Ibrahim, who was manning the checkpoint.

In August, militias from outside the Libyan capital were welcomed as liberators, but since then gunfights have become a daily occurrence.

Recent battles saw a militiaman shot dead on Tuesday in the city centre, and local media said a group of pro-Gaddafi gunmen tried to storm a hospital on Monday before being beaten back by government-backed fighters.

Fighting in western Libya has seen Tunisia close its border and Tunis Air suspend flights to Tripoli after gunmen boarded an aeroplane searching for an enemy.

But while the crackdown, implemented by local militias, may restore order to Tripoli, it leaves wider political problems unresolved.

More than three months after the capital fell, there is still no effective government in Tripoli or Libya.

The ruling National Transitional Council remains in the eyes of its critics a secretive organisation that has yet to broaden its base, or to integrate the country's militias into a single security authority.

While oil is now flowing at half its pre-war level, 840,000 barrels a day, much of the rest of the Libyan economy is at a standstill.

With financial transparency mechanisms still to be established, most of Libya's £10bn in foreign assets remains frozen by the UN.