TRIPOLI (AFP) – Residents of Tripoli cowered in their homes Sunday as US President Barack Obama hoped to avert a bloody battle for the Libyan capital by urging a defiant Moamer Kadhafi to step down "now."

Libya's former justice minister late Saturday announced the formation of a transitional government, which will include military representatives, that will pave the way for free elections in three months' time.

"Our national government has military and civilian personalities. It will lead for no more than three months, and then there will be fair elections and the people will choose their leader," said Mustafa Abdel Jalil.

Abdel Jalil was speaking in an interview on Al-Jazeera television from the eastern town of Al-Baida, near Benghazi, where the protests against Kadhafi's rule ignited on February 15.

It was not immediately clear whether other cities that liberated themselves had coordinated the move with Abdel Jalil, who resigned from Kadhafi's government on Monday in protest at his brutal crackdown against protesters.

In Washington, Obama said Kadhafi needs to "leave now," having lost the legitimacy to rule, a White House statement said.

The call came as UN Security Council envoys began tough negotiations on how to sanction the Libyan leader for a deadly crackdown that Tripoli's mission to the United Nations said had killed thousands of protesters.

Rebels have taken control of most of eastern Libya and were closing on the capital, where Kadhafi loyalists have been carrying out his orders kill opponents, witnesses said.

Khadafi's son, Seif al-Islam Kadhafi, earlier told Al-Arabiya television that the crisis had "opened the doors to a civil war."

The Libyan leader still controls the capital of the oil-rich state, where a resident told AFP tanks and all-terrain vehicles driven by regime partisans were patrolling the semi-deserted streets.

People had earlier Saturday joined long queues for bread and petrol.

But the witness said there was no sign of the African mercenaries who have reportedly been working for Kadhafi, and that this was a worrying sign.

"There are no more mercenaries, and that's serious because that means it will be Libyans against Libyans and the risk of civil war."

Amid the fear, he said there had been no calls on Facebook or telephone texts for people to demonstrate.

The White House said Obama took the position -- his most direct yet -- in a telephone call with German Chancellor Angela Merkel to coordinate efforts in response to the crisis.

"The president stated that when a leader?s only means of staying in power is to use mass violence against his own people, he has lost the legitimacy to rule and needs to do what is right for his country by leaving now," it said.

Obama and Merkel "discussed appropriate and effective ways for the international community to respond," the statement said.

Kadhafi, whose forces have melted away as the insurrection swept through most of the east of the country, showed he still possessed the power to strike back viciously at his opponents.

Helicopter-borne mercenaries fired on protesters at a funeral in the western city of Misrata, which fell under the control of protesters during the week, a witness told AFP.

Heavy weapons fire was heard in the background as the witness said by phone that mercenaries shot at relatives of the victims who were about to enter a mosque, adding the mercenaries also fired on a building housing an opposition radio station.

It was unclear if there were casualties. The city, Libya's third largest, was reported by residents to have been deserted by loyalists on Friday, amid continued pockets of resistance.

Britain announced that it had pulled its diplomatic staff out of Tripoli and closed its embassy. Staff were evacuated on the last government-chartered flight from the capital, it said.

The United States and Canada have also closed their embassies, and Paris suspended operations at the French embassy.

In a separate operation, two British C130 Hercules military transports swooped over the desert to evacuate 150 civilians stranded in the country's southern oilfields, Defence Minister Liam Fox said.

Other countries also scrambled to get their citizens out amid the threat of civil war in the oil-rich north African state.

Libya's foreign legion of domestic helpers, construction workers and oil executives were among thousands who scrambled to evacuate by air, land and sea on Saturday in a vast exodus.

A British warship and a Chinese-chartered ferry docked in Malta with 2,500 people from Libya's vast multinational workforce.

Bangladesh, China, Egypt, India, Nigeria, the Philippines and South Korea are among the countries that have or had large communities in Libya -- drawn by an oil boom that has brought billions of euros (dollars) in investments.

More than 38,000 people, mainly Tunisians and Egyptians, have fled Libya across Tunisia's main Ras Jedir border since the start of the exodus a week ago, a Tunisian official told AFP.

Libya's UN ambassador, a childhood friend of Kadhafi, delivered an emotional speech to the Security Council, raising the spectre of Hitler, Stalin and Pol Pot, asking for his country to be saved.

The UN World Food Programme warned on Friday the food distribution system was "at risk of collapsing" in the mainly desert North African nation which is heavily dependent on imports.

UN chief Ban Ki-moon has demanded decisive Security Council action, warning any delay would add to the growing death toll which he said came to more than 1,000.

In his interview with Al-Arabiya, Seif al-Islam said protesters were being manipulated in a situation which had "opened the doors to civil war."

"Our Arab brothers pay monthly salaries to journalists and tell them to write and incite against Libya, write against Moamer Kadhafi," he told the Dubai-based television channel.