CAIRO — The United States closed its embassy in Libya on Saturday and evacuated the embassy’s staff under military guard, in what the State Department said was a response to escalating violence in the Libyan capital, Tripoli.
Officials called the evacuation temporary and said they were looking for ways to reopen the embassy, even as the State Department issued a new travel warning Saturday, advising US citizens to leave Libya “immediately.”
Weeks of heavy fighting between rival Libyan militias for control of Tripoli International Airport had in recent days edged closer to the heavily fortified embassy, which is on the main road to the airport. The clashes have all but destroyed the airport, severely limiting air travel to Libya.
The embassy staff was evacuated over land, traveling in convoys to neighboring Tunisia under the watch of US military aircraft, according to a statement from the Pentagon.
Speaking in Paris during a series of diplomatic meetings about Gaza, Secretary of State John Kerry said the embassy was evacuated because of “freewheeling militia violence.”
The evacuation, which follows the withdrawal of other foreign diplomats, deepened Libya’s isolation at a moment when violence appears to be spiraling out of control.
Libya’s weak central government has been powerless to halt weeks of broadening battles in Tripoli and Benghazi, the country’s two largest cities, which have succumbed to a growing lawlessness and bloodshed.
‘The Libyan government has not been able to adequately build its military and police forces and improve security.’
As the militiamen have fought with heavy weapons in residential neighborhoods, with no central army to stop them, armed groups have stepped up a campaign of assassinations and kidnappings targeting political activists, journalists, and human rights workers.
The chaos has unnerved Libya’s neighbors, including Egypt, which has expressed alarm about militant groups operating on Libyan soil. Two weeks ago, the United Nations withdrew its staff from Tripoli in response to the fighting there, and Turkey said Friday it had suspended operations at its embassy in Tripoli.
The United States last closed its embassy in February 2011, during the Libyan revolt against the country’s longtime dictator, Moammar Khadafy. The Obama administration later opened a diplomatic post in eastern Libya, in Benghazi, an area that was under the control of anti-Khadafy forces.
In 2012, militants attacked the Benghazi mission, which included an annex used by the CIA, killing the ambassador, J. Christopher Stevens, and three other people. The embassy in Tripoli had served as a base for investigators from the Department of Justice investigating the Benghazi attack.
The current US ambassador, Deborah K. Jones, tweeted about the approaching violence during the past few days.
“A Libyan citizen reports from Gasr bin Ghashir indiscriminate shelling from early evening,” she tweeted July 19, referring to a neighborhood abutting the airport.
The next day, she tweeted about “heavy shelling and other exchanges” in the embassy’s neighborhood. On Wednesday, she tried to tamp down a rumor that US drones were operating over Libyan airspace.
“We are not engaged in this fighting, just trying to stay safe under fire,” she tweeted.
During the evacuation early Saturday, residents in Tripoli reported hearing the sounds of airplanes overhead and said there was a two-hour interruption of Internet service.
A Pentagon spokesman, Rear Admiral John F. Kirby, said that evacuation, which took about five hours, was secured by US Marines who had been working at the embassy and by military aircraft, including F-16s.
In a statement Saturday, Marie Harf, a State Department spokeswoman, said the decision to evacuate was not made lightly.
“Securing our facilities and ensuring the safety of our personnel are top department priorities,” she said, adding that the United States was “currently exploring options for a permanent return to Tripoli as soon as the security situation on the ground improves.”
After the withdrawal Saturday, the embassy compound sat empty and unguarded. No one answered at the front gate.
A man, driving away from the compound and clearly frustrated, asked a reporter if he worked at the embassy. “There was no one here,” he said.
The Americans had been processing documents for him — he did not specify what kind — but now, those documents were stuck inside.
In its warning, the State Department urged Americans already in Libya to leave immediately.
‘‘The Libyan government has not been able to adequately build its military and police forces and improve security,’’ it said. ‘‘Many military-grade weapons remain in the hands of private individuals, including antiaircraft weapons that may be used against civilian aviation.’’
The Obama administration has been particularly sensitive about security of US government employees in Libya since the Benghazi attack. It is still facing criticism from Republicans and others that it did not take the needed steps to enhance security in Benghazi or evacuate the mission amid the rising violence in that city in the months before the attack.