The United States shut down its embassy in Libya on Saturday and evacuated its diplomats to neighboring Tunisia under U.S. military escort amid a significant deterioration in security in Tripoli as fighting intensified between rival militias, the State Department said.

“Securing our facilities and ensuring the safety of our personnel are top Department priorities, and we did not make this decision lightly. Security has to come first. Regrettably, we had to take this step because the location of our embassy is in very close proximity to intense fighting and ongoing violence between armed Libyan factions,” State Department spokeswoman Marie Harf said.

Personnel, including the U.S. Marines who guard the embassy, were evacuated by land with F-16 fighters and Osprey helicopters providing security, the Defense Department said in a release.

The withdrawal underscored the Obama administration's concern about the heightened risk to American diplomats abroad, particularly in Libya where memories of the deadly 2012 attack on the U.S. mission in the eastern city of Benghazi are still vivid and the political uproar over it remain fresh ahead of a new congressional investigation into the incident.

On Friday, U.S. Ambassador to Libya Deborah Jones appealed for fighting near the embassy to stop. "We have not been attacked but our neighborhood a bit 2 close to the action," she tweeted. "Diplomatic missions 2 B avoided pls."

On Sunday, Jones tweeted about "heavy shelling and other exchanges" of fire in the vicinity of the embassy and speculation about the potential evacuation had been rife at the State Department for more than a week.

The evacuation was accompanied by the release of a new State Department travel warning for Libya urging Americans not to go to the country and recommending that those already there leave immediately.

"The Libyan government has not been able to adequately build its military and police forces and improve security," the travel warning said. "Many military-grade weapons remain in the hands of private individuals, including antiaircraft weapons that may be used against civilian aviation."

The State Department said embassy operations will be suspended until a determination is made that the security situation has improved, it said.

The U.S. is the latest in a number of countries to have closed down their diplomatic operations in Libya. Turkey on Friday announced that it had closed down its embassy and militia clashes in Benghazi have prompted the United Nations, aid groups and foreign envoys to leave.

Tripoli has been embroiled for weeks in inter-militia violence that has killed and wounded dozens on all sides. The fighting has been particularly intense at the city's airport and forced residents to evacuate their homes nearby after they were hit by shells.

The battle in Tripoli began earlier this month when militias — mostly from the western city of Misrata — launched a surprise assault on the airport, under control of rival militias from the western mountain town of Zintan. On Monday, a $113 million Airbus A330 passenger jet for Libya's state-owned Afriqiyah Airways was destroyed in the fighting.

The rival militias, made up largely of rebels who once opposed longtime leader Moammar Gadhafi, have forced a weeklong closure of gas stations and government offices. In recent days, armed men have attacked vehicles carrying money from the Central Bank to local banks, forcing their closure.

Libyan government officials and activists have increasingly been targeted in the violence. Gunmen kidnapped two lawmakers in the western suburbs of Tripoli a week ago and on Friday armed men abducted Abdel-Moaz Banoun, a well-known Libyan political activist in Tripoli, according to his father.

Al Jazeera and wire services