The U.S. Consulate in Benghazi is seen in flames during a protest by an armed group, on Sept. 11, 2012. (ESAM OMRAN AL-FETORI/REUTERS)

For more than two decades, federal law has required the State Department to select the cheapest, rather than the best, contractor to provide local guard services at its embassies abroad.

The “lowest price” provision, a half-sentence buried in 1990 legislation designed to give U.S.-owned security companies an edge in contract bidding, applies to virtually no other part of the U.S. government.

The contract provision has not been singled out as a factor in security lapses surrounding the Sept. 11 militant attack on a U.S. diplomatic mission in Benghazi, Libya, although investigations found that local guards did little help to fend off the assault and may have been complicit with the attackers.

The contracting of local guards is only one of the many issues lawmakers plan to raise when they grill outgoing Secretary of State Hillary Rodham Clinton on Wednesday in hearings in the Senate and the House on Benghazi and the broader problems of protecting U.S. diplomats in an increasingly hostile world.

Clinton will probably be asked about the results of security assessments at 19 “high risk” posts in 13 countries, which were conducted immediately after the Libya attack, and about plans to add 35 Marine detachments to protect embassies. She is also expected to be questioned about the security improvements recommended by an independent panel after the Benghazi attack.

Many U.S. diplomats worry that their ability to work overseas will be restricted severely because of the attack in Libya, in which U.S. Ambassador J. Christopher Stevens and three other Americans were killed.

“Chris could have been any one of us,” said Cameron Munter, who was the U.S. ambassador to Pakistan until last summer. “You have to accept a certain amount of danger if you expect to do your job.”

Fallout from Benghazi has brought new scrutiny, but problems with diplomatic security are far from new. The State Department is required by law to assess the security environment for its diplomatic facilities every six months, dividing them into four categories of threat level, from low risk to critical. In its 2013 budget request, the department said it was developing a new category, “critical plus,” for facilities that required more “innovative” security measures.

Government commissions and the department’s inspector general have repeatedly expressed concern about the danger of trading security value for cost savings.

In an inspector general audit last February, two-thirds of embassy security chiefs reported problems with local guards, and more than half said conditions would improve if they were allowed to skip the lowest-price standard and hire security based on the “best value” criteria, which weighs experience, past performance, reliability and training of bidders.

In 2009, Congress passed exemptions from the low-price standard for embassies in Iraq, Afghanistan and Pakistan because of security concerns. Those measures have expired, but they remain in place because new budgets have not passed and the government runs on continuing resolutions.

Sen. Robert Menendez (D-N.J.), the incoming chairman of the Senate Foreign Relations Committee who will preside over the Clinton hearing in the Senate, has drafted legislation that would allow the best-value standard for all embassies, a senior Menendez aide said last week.

More money has not always bought better security. A State Department document from July published last week by the independent Project on Government Oversight reported a “mutiny” by guards against their supervisor at the U.S. Embassy in Kabul, a facility that has come under repeated Taliban attack. In a memorandum to Aegis, a British security contractor, the embassy said the supervisor’s actions “put the security of the Embassy at risk” and asked that he be removed.

In Pakistan, where about 2,840 local guards provide outer-rim security for the U.S. Embassy, official residences in Islamabad and consulates in Karachi, Lahore and Peshawar, contract fees have nearly doubled since 2007 to $9.3 million a year.

Still, the consulate in Peshawar has been attacked so many times that staff members who are frequently moved to Islamabad are known inside the embassy as “Pesh-ugees.”

There have been suggestions that U.S. diplomatic compounds, often regarded as fortresses, should have even higher walls and that some consulates should be closed. After U.S. troops were withdrawn from Iraq, the State Department began cutting its massive civilian presence there by more than half.

In Afghanistan, the State Department is anticipating a significantly smaller diplomatic profile after combat troops depart. The Provincial Reconstruction Teams, which distribute U.S. aid nationwide and were a bulwark of the counterinsurgency program, are being shut down, and initial plans for consulates in Kandahar and Jalalabad are likely to be abandoned. In Mazar-e Sharif, civilian officials remain on an American military base after an initial consulate site was deemed insecure. In Herat, a consulate that opened last summer with great fanfare is inside a heavily guarded hotel.

In Sanaa, the capital of Yemen, the U.S. Embassy has come under repeated attack from protesters and extremists. Al-Qaeda in the Arabian Peninsula announced last month that all Americans in the country were targets, singling out the ambassador and U.S. troops. Embassy staff members live in the heavily fortified Sheraton Hotel, which the U.S. government is negotiating to purchase.

In Mali, where U.S.-backed French and African troops are fighting against another al-Qaeda affiliate, the U.S. Embassy in Bamako is a well-protected fortress on 16 acres. It was built in 2006 under rules adopted after al-Qaeda allies blew up embassies in Kenya and Tanzania in 1998.

Criticism of the post-1998 high-security fortresses inspired the State Department in 2010 to invite prominent architects to come up with creative designs within the mandated blast walls and set far back from roads. The new embassy under construction in London retains an urban, leafy setting on the south bank of the Thames River. But the compound is protected by a partial moat and the ubiquitous high walls designed to thwart vehicle bombs and grenade launchers.

Despite such efforts, the Congressional Research Service concluded in a November report that “the Department of State currently maintains a presence in locations faced with security conditions that previously would have led State to evacuate personnel and close the post.”

Still, a sampling of former ambassadors by The Washington Post found them focused less on personal safety than on fear that new restrictions will make diplomacy more difficult than ever.

Following Stevens’s death, “what I’ve been hearing is along the lines of, ‘Oh, God, please may they not clamp down and make it impossible to work,” said Ryan Crocker, who served as ambassador to Afghanistan, Pakistan, Iraq and Syria, among other trouble spots.

No matter how well fortified and guarded their embassies and consulates are, diplomats “might as well be based in Warrenton or Arlington” if they can’t travel outside them, said Matthew Bryza, who was the U.S. ambassador to Azerbaijan when an Iranian-backed plot to kill U.S. diplomats there was uncovered in late 2011.

The preparation and expanse of travel outside the embassy fortress is already too burdensome in many places. “I didn’t get up to the north as much as I wanted, which is ironic because it’s the safest place in the country,” said Munter, the former ambassador to Pakistan.

When he flew to the far reaches of Pakistan, a caravan of armored vehicles had to drive to the location, often across dangerous territory, to guard and assist him on the ground, Munter said. “We wanted to show the flag, but the benefits were not outweighed by the cost and risk to the people going there,” he said.

Fortresses will never be enough, Bryza said. “You’ve got to have great intelligence, host government support . . . and, of course, decent walls and guards.”

Sudarsan Raghavan and Ernesto Londoño contributed to this report.