American forces operating inside Libya have been temporarily evacuated, the US military's top commander for Africa said, as clashes between rival militias raging on the capital's outskirts raise the spectre of all-out urban war.
"The security realities on the ground in Libya are growing increasingly complex and unpredictable," Marine Corps General Thomas Waldhauser, head of US Africa Command, said.
The temporary US pullout, after evacuations by other countries and international businesses, underscored the fluid and tenuous environment in the country three days after a renegade commander from eastern Libya launched an offensive to seize Tripoli.
The UN-backed government in Tripoli vowed to defend the capital against General Khalifa Hifter, declaring that his intention is to stage a military coup.
At least 21 people had been killed and 27 wounded, a spokesman for the Tripoli government said.
The small contingent of US forces in Libya has been providing military support for counterterrorism activities and diplomatic missions and has served to bolster security in the region, the statement said. Waldhauser did not discuss where the US forces, who reportedly were taken out of Tripoli on fast amphibious boats, have been relocated to or when they intend to return.
Hifter, a US citizen who lived in Northern Virginia for years, is aligned with a rival government based in the eastern city of Tobruk.
The offensive threatens to throw Libya into full-blown civil war and usher in the most significant escalation of violence since the 2011 overthrow of dictator Muammar Gaddafi by a popular rebellion backed by Nato airstrikes.
Hifter has refused to heed calls by the United Nations as well as Western and Arab nations - including some of his key backers - to halt his military push.
As the fighting heats up, so has the public rhetoric. In a televised address, the president of the Tripoli-based government said he had been "stabbed in the back" by Hifter after having offered him certain trade-offs to pave the way for a peaceful reconciliation.
"We have extended our hands toward peace, but after the aggression that has taken place on the part of forces belonging to Hifter, he will find nothing but strength and firmness," said President Fayez Serraj, promising to eradicate Hifter's forces from the country.
Fighters loyal to Hifter clashed with pro-government forces in neighbourhoods south and west of Tripoli, including near the old, now-defunct international airport that Hifter's forces claimed to control. Dozens of militias have poured into Tripoli from cities such as Misurata and Zintan to join forces with pro-government militias to fend off Hifter.
The fighting was so fierce that the United Nations called for a two-hour truce so that the injured and vulnerable civilians could be evacuated. But it was unclear whether the warring sides had agreed to the request.
A Hifter spokesman said that at least 14 of the general's fighters have been killed. And the media arm of the Hifter force said on its Facebook page that his warplanes had carried out their first strike - a day after pro-government jets pummelled Hifter's positions.
India's external affairs minister said the country had evacuated its 15-strong contingent of police officers serving as peacekeepers. The Italian oil company Eni also said it would withdraw all its Italian employees.
In recent months, Hifter's self-described Libyan National Army has swept east and across southern Libya, taking control of areas often without encountering much resistance. On Friday, it pushed north and took over a town 95km south of the capital.
Hifter then gave orders for his forces to march on Tripoli, even as UN Secretary General António Guterres was in the Libyan capital preparing for a much-anticipated reconciliation conference between the warring sides intended to pave the way for long-delayed elections.
The UN has declared that the gathering will go on as planned. That, however, will depend on whether Tripoli descends into urban warfare.