At least 37 people killed and hundreds hurt after Misrata unit opens fire on crowd of demonstrators

Libyan capital was braced for fresh violence on Saturday night after a day in which at least 37 were killed and more than 400 wounded in a confrontation outside a militia headquarters.

In some of the bloodiest fighting since the overthrow of Muammar Gaddafi, a Misrata militia unit opened fire on protesters who had massed outside their Tripoli base, demanding they leave the city.

Hospitals were overwhelmed with the dead and wounded and prime minister Ali Zeidan appealed for calm, declaring three days of national mourning.

The UN and European Union evacuated non-essential staff from Libya on Saturday, with foreign embassies going into security lockdown.

Witnesses said that anti-aircraft weapons were fired at the protesters outside the base in the city's Gharghur district, amid conflicting reports of who fired first. The demonstrators, including women and teenagers, many carrying white placards and flags, fled the firing seeking the shelter of nearby houses.

Witness Majdi Elnakua, a photographer, said that he watched as a woman pleaded with her sister to run from the doorway of a nearby house where she was sheltering from the firing. "She was shouting for her sister to come out and run," he said. "Her sister came out, she ran some steps, then a bullet hit her. The force pushed her against the wall and she fell down. She was dead, her blood was on the wall, it was unbelievable."

TV footage showed militiamen deployed around the base firing heavy machine guns from the flatbeds of pick-up trucks. A spokesman for the Misrata militia unit, Taha Basha Agha, insisted that some protesters had been armed and had fired first, shooting from nearby rooftops. He said his unit would stay in its base, telling a TV station: "We will leave in our coffins."

fresh Misratan militia units arrived to bolster its force in the city, taking up positions in the eastern Tajora district. Opposing Tripoli militias, police and army units blocked roads across the capital, deploying tanks on the coastal highway. Skirmishes broke out as night fell, with lines of red tracer fire darting through the sky.

The violence underscores the inability of Libya's government to rein in the powerful militias, who formed during the revolution but have since become a law unto themselves, with the government weak and national congress divided. "I don't see how it can get better. The cause of the violence is always the same, its these militias, all of them, I don't put the finger to a particular one," said Hassan El Amin, a former Libyan dissident who fled back to Britain last year after receiving militia death threats. "Congress is disabled. I don't expect anything from congress."

Elsewhere in Libya, tribal militias and striking army units continued their five-month blockade of the bulk of the country's oil ports, depriving the country of its main source of income. The prime minister was himself kidnapped by a militia force in Tripoli last month and held for six hours before being released by local residents.

On Saturday thousands converged on Tripoli's central Martyrs' Square for an emotional protest, praying for peace, and funerals took place across the city.

Mediation efforts between Tripoli and Misrata leaders were under way but few in the capital expect success.

Britain will join Italy, Turkey and the United States in training recruits for a fledgling Libyan army beginning in January, with diplomats saying that the government forces are currently too weak to oppose the militias.