The volatile demonstrations at U.S. diplomatic missions this week have shattered any illusions about the inviolability of America’s envoys and highlighted the perils of diplomatic life in a region undergoing sweeping political upheaval.

The protests — and the ferocious attack that killed U.S. Ambassador J. Christopher Stevens and three other Americans in Libya — have prompted officials to order a review of security measures in every overseas diplomatic mission. The unrest is also likely to reinvigorate an ongoing debate over whether the State Department has enough resources to protect its personnel at its 400 embassies, consulates and other diplomatic outposts.

The State Department said Thursday that the security at the U.S. Consulate in Benghazi, where the four Americans were killed, was consistent with the security at similar missions, with a local guard force on the perimeter and an American security presence inside. A spokeswoman noted that the department had recently assessed security at missions around the world in advance of the anniversary of the Sept. 11 terrorist attacks.

“We determined that the security at Benghazi was appropriate for what we knew,” said the spokeswoman, Victoria Nuland.

But the attack underlined concerns that the State Department has not adequately prepared for the security threats in some countries in which it has expanded operations.

The challenge has been best exemplified by the U.S. military’s withdrawal from Iraq, which has left the State Department with a shortage of officials experienced in dealing with explosive ordnance, and rocket and mortar countermeasures.

Last year, a report by the Government Accountability Office concluded that the State Department’s Bureau of Diplomatic Security has struggled to keep “up with the changing high threat environment” in foreign capitals in Iraq, Pakistan and Sudan.

“State is maintaining a presence in an increasing number of dangerous posts, is facing staff shortages and other operational challenges that tax Diplomatic Security’s ability to implement all of its missions and has not provided Diplomatic Security with adequate strategic guidance,” the GAO’s Jess T. Ford told a House subcommittee.

In Libya, where Moammar Gaddafi has been replaced with a pro-Western government, foreign diplomats have been the target of extremist violence on a handful of occasions, including in April when armed groups exploded a roadside bomb directed at a U.N. convoy carrying the organization’s top representative, Ian Martin. In June, armed groups attacked a British convoy carrying Britain’s ambassador to Libya, Dominic Asquith. The ambassador was unharmed, but two British guards were injured.

“It is a real shock which should remind everyone of the dangers of diplomacy,” France’s U.N. ambassador, Gerard Araud, said this week after the attack in Libya.

His government has lost two ambassadors in the past three decades, Philippe Bernard in Congo in 1993, and Louis Delamare, who was gunned down in Lebanon in September 1981.

“It takes a great deal of courage to accept these risks,” Araud said. “This attack is even more despicable in that our job is about dialogue, about building bridges to preserve peace.”

The attack in Benghazi was the most significant assault on a U.S. diplomatic outpost since the 1998 bombing of embassies in Tanzania and Kenya. Those bombings killed 224 people, including 12 Americans, and led to a movement to reinforce U.S. missions.

The security measures in missions worldwide vary. The U.S. Consulate in Benghazi, officials said Thursday, was not staffed by Marines. But Nuland said that it was not unusual for a consulate of its type.

“We make a decision based on the local conditions as to whether that makes sense. But this posture that we had, which was external security by the Libyans, and then a strong U.S. security presence, but it didn’t include that particular contingent of Americans inside,” she said.

Some in the diplomatic community said Thursday that while they were reminded of the dangers of service, they were also concerned that the attack in Libya could prompt an overreaction, leading to even tighter security that could impair their work.

“We have to take the long view on finding a balance between security and getting the job of diplomacy done,” said Edward Djerejian, a former U.S. ambassador to Syria and Israel and founding director of the James A. Baker III Institute for Public Policy at Rice University. “You cannot conduct American diplomacy from a fortress. No American can do his job without taking a certain risk. Those risks should be managed, but without the illusion that there is something called absolute security.”