Activists in Berlin protesting for more information about the cooperation between the National Security Agency and the German federal intelligence service hold a banner calling for former NSA employee Edward Snowden to come to Germany to testify in this September file photo. (Sean Gallup/Getty Images)

In a crescendo of anger over American espionage, Germany expelled the CIA’s top operative, launched an investigation of the vast U.S. surveillance programs exposed by Edward Snowden and extracted an apology from President Obama for the years that U.S. spies had reportedly spent monitoring German Chancellor Angela Merkel’s cellphone.

In an address to Parliament last year, Merkel warned that U.S.-German cooperation would be curtailed and declared that “trust needs to be rebuilt.”

But the cooperation never really stopped. The public backlash over Snowden often obscured a more complicated reality for Germany and other aggrieved U.S. allies. They may be dismayed by the omnivorous nature of the intelligence apparatus the United States has built since the Sept. 11, 2001, attacks, but they are also deeply dependent on it.

Over the past year, Germany has secretly provided detailed information to U.S. spy services on hundreds of German citizens and legal residents suspected of having joined insurgent groups in Syria and Iraq, U.S. and German officials said.

Germany has done so reluctantly to enlist U.S. help in tracking departed fighters, determining whether they have joined al-Qaeda or the Islamic State and, perhaps most importantly, whether they might seek to bring those groups’ violent agendas back to Germany.

The stream of information includes names, cellphone numbers, e-mail addresses and other sensitive data that German security services — ever mindful of the abuses by the Nazi and Stasi secret police — have been reluctant even to collect, let alone turn over to a suspect ally.

A senior German intelligence official compared the U.S. relationship to a dysfunctional marriage in which trust has bottomed out but a breakup is not an option. Amid what Germans see as evidence of repeated betrayal, “the question remaining is whether the husband is a notorious cheater or can be faithful again,” said the official, who like others interviewed for this article spoke on the condition of anonymity to discuss intelligence matters. “We’re just going to have to give it another try. There is no alternative. Divorce is out of the question.”

More than 550 German citizens have gone to Syria, officials said, and at least nine have killed themselves in suicide attacks.

The exodus is part of a much broader flow of more than 15,000 foreign fighters who have entered Syria over the past four years from 80 countries. At least 3,000 of them are from Europe — the largest contingent of Islamist jihadists with Western passports that counterterrorism agencies have ever faced.

As a result, nearly every country in Europe is turning over significant data on their own departed fighters to the United States. Some of these nations, including Germany, have capable security and intelligence agencies of their own. But even their combined resources probably cannot match the scope and reach of their U.S. counterparts.

Indeed, the United States appears to be the only country even attempting to compile a comprehensive database of all the foreign fighters who have crossed into Syria. The National Counterterrorism Center (NCTC) adds new entries almost every week, often starting with only fragments of fighters’ identities and then filling in other details drawn from the arsenal of U.S. intelligence assets now aimed at Syria.

Even if only a small percentage of fighters in Syria were ever to pose any significant threat, their exposure to the country’s violence and their potential associations with the Islamic State or the al-Qaeda affiliate Jabhat al-Nusra make them part of a generation that is likely to be monitored by security services long after the fighting in Syria and Iraq ends.

“We’re looking at this as a decadal issue,” said a senior U.S. intelligence official involved in producing classified assessments on the Syria threat. “Even if the numbers stopped growing today — if we only had the 15,000 — you’re still looking at a global issue that is going to carry on for a number of years and that is going to test the bandwidth and resources not only of us, but our foreign partners.”

Crossing borders

In the past year, Germany and other nations have adopted measures to prevent citizens suspected of planning to join insurgent groups from leaving. Some have begun seizing passports of would-be fighters. But the restrictions vary by country, are riddled with holes and have only partially obstructed key paths into Syria.

From Europe, the main route remains through Turkey, which is not part of the European Union but is effectively treated as one in terms of travel. European citizens don’t need passports to fly into the country ,where thousands of fighters have made their way by car, bus or foot across Syria’s broken borders.

Fighters coming back to Europe face similarly inconsistent scrutiny. European laws designed to prevent discrimination don’t permit “systemic” checks of citizens reentering the E.U. from abroad, in contrast to the United States, which screens virtually every incoming traveler against counterterrorism databases.

Security officials across Europe are pushing to relax that ban and other constraints but said doing so could take years.

Inside Europe, borders and passport controls have been largely erased over the past two decades, enabling Europeans to move across national boundaries much the way Americans cross state lines. The result is a patchwork defense in which even countries that manage to track their own foreign fighters have addressed only a portion of the threat.

“Of course we know most about our 550,” Emily Haber, state secretary in Germany’s interior ministry, said in an interview. “But there are 3,000 union citizens in Syria, and they can travel freely within [Europe’s] borders.”

Germany served as the point of entry for a returning fighter who earlier this year carried out the most deadly attack in Europe traced to the conflict in Syria.

When Mehdi Nemmouche, a 29-year-old French citizen of Algerian descent, arrived in Frankfurt on March 18, German authorities noted that he was the subject of a “silent alert” entered in the European travel system. They notified their French counterparts that Nemmouche was back in Europe, but they allowed him to proceed because the secret notification made no mention that Nemmouche had been in Syria and did not request that he be detained.

Nemmouche traveled unimpeded back to France and then crossed the border into Belgium, where on May 24 he launched an assault on a Jewish museum in Brussels in which he shot and killed four people. He was apprehended a week later back in France, still carrying his weapons.

“The subtext is very clear,” Haber said. “Individual perpetrators can attack wherever they like and whenever they like in European territory, no matter their citizenship.”

Haber said German authorities are on higher levels of alert now, and she cited a June case in which another French fighter returning from Syria was apprehended after German officials became suspicious and secured an arrest warrant from their counterparts in France.

But others said the gaps exploited by Nemmouche persist. There have been no structural changes to Europe’s travel security systems, which generally don’t allow nations to explain why silent alerts are issued or for travelers to be detained unless there is enough evidence for an arrest.

“As long as there is no arrest warrant, this gap indeed remains,” said Clemens Binninger, the head of the German parliamentary committee that oversees the nation’s intelligence agencies. “But, of course, in order to obtain an arrest warrant you need to have information. That is why this is such a huge challenge to keep track of all these travelers to Syria or detain them.”

Sharing capability

For decades the U.S.-German intelligence relationship had been defined by the Cold War. After the Sept. 11 attacks, the United States sought to enlist Germany against a new adversary: al-Qaeda.

Michael V. Hayden, who was then director of the National Security Agency, described taking his German counterpart, August Hanning, on a Sunday driving tour of Civil War sites surrounding Washington to lay the groundwork for a wave of requests.

“I was asking for deeper operational cooperation,” Hayden said.

It came, although the relationship was routinely strained by espionage-related embarrassments. Among them were the realizations that Iraq weapons claims by a German source code-named “Curveball” had been fabricated and that the CIA had mistakenly abducted a German citizen it thought was part of al-Qaeda.

The Snowden disclosures triggered an eruption of much greater force.

“This is complete surveillance. It turns everybody into a suspect,” said Hans-Christian Ströbele, a member of Parliament who visited Snowden in Moscow last year. “The NSA can do much more than the East German secret police could in their wildest dreams,” he said, although he acknowledged that U.S. agencies “haven’t used their knowledge for the same ends.”

But the Snowden files also exposed how costly it might be for officials in Berlin to sever ties with U.S. intelligence.

One 2013 memo described how the NSA had “provided a significant amount of hardware and software” to the BND, the German foreign intelligence service, which in turn was “working to influence the German government to relax interpretation” of privacy laws. The memo referred to Germany’s repeated requests for help intercepting communications over Skype, an online network the Germans had apparently failed to crack.

Another document disclosed that the NSA had given Germany’s domestic intelligence service a potent software tool. Called XKEYSCORE, it serves as a sort of search engine for electronic espionage, allowing agencies tapped into networks to zero in on specific cellphone numbers, keywords or even Web searches.

The senior German intelligence official said that the domestic agency, known as the Bundesamt für Verfassungsschutz, or BfV, had been given only a “test version” of the program and that it was being used to filter data gathered under domestic wiretaps approved by Parliament.

“We’re not allowed to search the big streams of intelligence data” or U.S. stockpiles, the official said. “We need XKEYSCORE so if we have a stream on an individual, we can filter the videos they download, e-mails they send or Web sites they visit.”

Though among Europe’s largest, Germany’s intelligence services are dwarfed by their American counterparts. The BND, which sends spies abroad and conducts electronic espionage, had a budget of approximately $650 million last year. By contrast, the CIA and NSA, which handle the same functions, had combined budgets approaching $25 billion.

The NSA “has better technical means, far more capacity, better software to deal with more data,” said Hanning, the former chief of the BND, or Bundesnachrichtendienst. The German agency can deliver impressive results when focused on narrow targets such as the crisis in Ukraine or threats to German troops in Afghanistan. But measured against the NSA, Hanning said, the BND’s capabilities are “less than 10 percent.”

A pragmatic relationship

As the flow of fighters into Syria surged last year, senior U.S. officials made a series of visits to Europe, and CIA station chiefs were told that getting details on foreign fighters from their European counterparts had become “the number one priority,” a former senior U.S. intelligence official said.

Most of the data has been obtained merely by asking, the former official said. But U.S. spy agencies have also stolen such information from reluctant counterparts, according to the official, who said that “in some cases we swipe it.”

At the NCTC, the database of foreign fighters is revised upward almost constantly, officials said, like a ticking odometer. Records on specific identities are filled out by teams of analysts sifting through the torrent of social-media postings from Syria, as well as the vast repositories of data extracted from Google, Facebook and other companies under PRISM and other programs revealed by Snowden.

Germany has turned over information on all of the approximately 550 departed fighters it has identified, although officials said there are undoubtedly many more they don’t yet know about. In doing so, Germany has essentially marked its departed citizens as surveillance targets for U.S. spy agencies, if not more. One German official described with dread a scenario in which a citizen identified for the Americans is killed in a U.S. strike.

German authorities assembled a detailed profile of its foreign fighter population earlier this year showing that about 61 percent were born in Germany. Most are between the ages 15 and 30, the vast majority of them Muslims who failed to complete school and face seemingly dim prospects even in Europe’s strongest economy.

So far, the U.S. collaboration has served as something of an insurance policy on which Germany has not had to collect. German officials said there has been near-constant intelligence “chatter” suggesting possible attacks on German soil but no evidence of a specific plot.

German officials bristled at the suggestion of inconsistency in Berlin’s willingness to accept intelligence presumably obtained by the U.S. programs and methods it had condemned. Several made the argument that Germany should not be criticized for receiving such intelligence, because U.S. spy agencies rarely disclose precisely how they got it.

German agencies “receive it in the form of so-called ‘finished intelligence,’ ” said Binninger, the chairman of Germany’s intelligence committee. “So you cannot draw the conclusion that the German authorities are being helped by information that they criticized a year ago.”

Others explained the relationship in coldly pragmatic terms.

“The phenomenon of our time is the mushrooming of terrorist movements,” Haber said, describing the Islamic State as a uniquely brutal terrorist organization that casts “a specific spell” on those who join it. The seriousness of that threat compels continued cooperation between the United States and Germany, she said, despite the residual resentment.

Hanning, the former BND chief, acknowledged the tension in Berlin’s position. “Sometimes it’s not so easy being in Germany,” he said. “We are living with this contradiction.”

Julie Tate in Washington and Anthony Faiola and Stephanie Kirchner in Berlin contributed to this report.