Weeks before he was sworn in, President-elect Barack Obama was given an extensive briefing on the secret operations of U.S. spy agencies, as well as a warning: “You need to give up your BlackBerry,” Obama was told, according to former officials familiar with the meeting. “If you use that phone, you are not just subject to monitoring — you will be monitored.”

Obama was at first not convinced of the danger and kept using the phone for several months, albeit with new encryption technology. But his intelligence chiefs were by then acutely aware of the vulnerability because they had been exploiting it to monitor the calls of German Chancellor Angela Merkel and other foreign leaders for years.

Those penetrations were so abundant — and in some cases so effortless — that they upended a long-standing equilibrium in espionage. Stealing secrets from adversaries, let alone allies, had always been limited by daunting logistics and the risk of what intelligence professionals call blowback — the costs associated with being discovered, whether by allies or enemies. Those Cold War constraints seemed to crumble in the Internet age.

Now that equilibrium is being scrambled again as U.S. spy agencies confront cascading disclosures of their secrets on a magnitude they never envisioned, triggered by a former intelligence contractor, Edward Snowden. This presents a new quandary for the United States: Curtail spying on allies and lose critical intelligence; or continue the programs and take on serious diplomatic risks if discovered.

The disorienting effect of Snowden’s revelations was evident as U.S. officials sought to contain the fallout during congressional testimony this week.

“The conduct of intelligence is premised on the notion that we can do it secretly, and we don’t count on it being revealed in the newspaper,” Director of National Intelligence James Clapper said, essentially acknowledging that a leak of Snowden’s scale was never factored into U.S. spy agencies’ cost-benefit analysis.

He and others seemed equally baffled that U.S. agencies were now being faulted for succeeding at what has always been among their principal objectives: gathering intelligence on the intentions of foreign leaders.

That success was enabled to a large degree by American spy agencies’ ability to take advantage of the rapid spread of digital communications networks across the globe. Senior lawmakers warned that U.S. agencies are only beginning to account for an accompanying expansion of risk.

“Our capabilities have grown dramatically, [but] our analysis of their costs and benefits has not grown with them,” said Democratic Rep. Adam Schiff, a member of the House Intelligence Committee. “What we’ve found out in the last year and a half with Snowden and Manning is that the potential for disclosure has grown equally dramatically.”

Bradley Manning, a former U.S. Army intelligence specialist, was convicted earlier this year of sharing a cache of classified diplomatic cables and other materials with the anti-secrecy website WikiLeaks.

The recent disclosures of National Security Agency monitoring of foreign leaders extend beyond Merkel, whose cellphone was under NSA surveillance as far back as 2002. Other stories based on Snowden documents indicate that the United States had hacked the email account of Felipe Caldern, then Mexico’s president, and monitored calls of at least 35 other foreign leaders, many of them U.S. allies.

The disclosures have provoked outrage and calls by leaders of Germany, France and other nations for agreements that would impose limits on U.S. espionage.

Obama has already told Merkel that her phone is no longer being monitored, and administration officials said they are discussing whether to extend similar assurances to other allied leaders.

Doing so would deprive the United States of intelligence that current and former American officials said has often given Washington an advantage in advancing its diplomatic aims. There is widespread skepticism among some officials that a new set of spy rules could be agreed upon, let alone enforced.

“I don’t see how this can be done on a rational, well thought out basis,” said Mark Lowenthal, a former senior official at the CIA and former staff member of the House Intelligence Committee. “I don’t think you can make a blanket statement to most of these countries. And if you do, you’re going to end up lying to them.”

Among the challenges, officials said, is deciding which countries are considered close enough to forgo certain categories of intelligence collection against them.

The United States has broad no-spying arrangements with Britain, Australia, Canada and New Zealand, a group known as the Five Eyes. But proposals to broaden that group have always broken down.

In 2010, Obama’s director of national intelligence, Dennis C. Blair, urged reaching a similar agreement with France, a country that works closely with the United States on counterterrorism and other issues. But White House officials killed the proposal, in part because of doubts that Paris could be trusted to honor an espionage ban, and Blair was soon pushed out of his job.

In an interview, Blair said that if he were still director, he would caution against placing new restrictions on intelligence collection against Germany, Spain and other allies angered by the Snowden revelations.

“If the current controversy results in prohibitions on gathering intelligence, then the decisions of our government will be less well informed,” Blair said. “For the United States to forgo the option of checking even on its partners with intelligence would diminish our security.”

Beyond the question of which countries might qualify for assurances, officials cited the difficulty of deciding where to set boundaries within the ranks of a given government. If the United States agrees not to spy on a head of state, “how about the deputy? How about the executive assistant? How about the secretary?” a former U.S. intelligence official asked. “It’s silly.”

Germany has threatened to cut off some of its intelligence cooperation with the United States. Merkel said last week that “the United States and Europe face common challenges. We are allies. But such an alliance can only be built on trust.”

American intelligence officials noted, however, that U.S. and German interests often diverge. Over the past decade, the two nations have quarreled over the Iraq war, sanctions on Iran — which purchased equipment for its nuclear program from German companies — and the decision to intervene in Libya.

Stressing the impracticality of imposing rules on spy services trained to break them, some U.S. officials said that the most meaningful new constraints are likely to be driven by changes in the way that spy agencies evaluate risks.

During the Cold War, gaining access to sensitive communications was such an enormous undertaking that resources were marshalled mainly against major adversaries. In the 1980s, the United States spent months digging a secret tunnel under the Soviet Embassy in Washington, only to learn later that the operation had been exposed by an FBI agent, Robert Hanssen, who was a Soviet spy.

By contrast, Clapper implied during his testimony this week that advances in technology had rendered such penetrations commonplace — so much so that it didn’t occur to U.S. intelligence officials to provide Obama or senior lawmakers with a list of high-level targets.

“We don’t necessarily report each and every selector,” Clapper said, using a term that implies that the surveillance of Merkel had been a matter of searching for keywords — names or phone numbers — among the billions of communications streams being intercepted every day.

In testimony before the House Intelligence Committee on Wednesday, Clapper was pressed to explain why U.S. intelligence officials hadn’t anticipated the now evident diplomatic risks of spying on allied heads of state.

“There are many things we do in intelligence that, if revealed, would have — might have — the potential for all kinds of blowback,” Clapper said. The fallout from Snowden’s disclosures “would change the criterion, obviously.”