The response was driven in part by the controversy over lax security at U.S. diplomatic installations in Libya last year, when four U.S. government employees, including Ambassador J. Christopher Stevens, were killed in a terrorist attack. Fallout from the Sept. 11, 2012, assault in Benghazi continues to be the subject of an intense political fight, with Republicans accusing the Obama administration of being negligent and attempting to cover up embarrassing facts.

The protests that have spread in Libya over the past week stem largely from the passage of a law that bars from public office officials who served in key roles under the deposed Libyan regime of Moammar Gaddafi. There is no indication so far that the demonstrators are targeting Westerners.

Still, a senior defense official said a Marine quick-response team and a Special Operations unit have been placed on alert to ensure that they can respond if they are needed to evacuate personnel. The nearest U.S. troops are stationed in Spain and Italy.

"The reason we're able to have these forces on alert is work the Defense Department has done to have additional response options in the wake of Benghazi," the official said, speaking on the condition of anonymity to discuss contingency plans.

The State Department said in a statement that it has ordered the departure of a handful of ­"non-essential" personnel from Tripoli as a result of the "unsettled situation," which includes mass protests outside government facilities.

"We have no indication that the current protests are directed toward Westerners," the statement said. "However, sporadic episodes of civil unrest have occurred throughout the country."

The British Embassy also evacuated some employees, the government said in a statement.

The State Department updated its Libya travel warning Thursday, advising against all but essential travel to Tripoli, Benghazi and other areas.

The unrest worsened after the country's new legislature last weekend overwhelmingly passed the bill barring certain figures from serving in government. It could unseat officials who currently hold important jobs.

A similar effort to ban former officials from working in the Iraqi government after the 2003 fall of Saddam Hussein was one of the driving factors of the Sunni insurgency there. Diplomats and analysts have expressed concern that Libya's law is too broad — potentially marginalizing a large segment of the population, which could resort to violence.

"The international community is observing the country with concern during this critical time in the transition," France, Britain and the United States said in a joint statement this week, in which the governments that helped topple Gaddafi during the 2011 civil war called for restraint. "We support Libya's successful transition from ruthless dictatorship to democracy, stability and prosperity.