Turkish Prime Minister Ahmet Davutoglu, center, Interior Minister Efkan Ala, left, and Defense Minister Ismet Yilmaz, right, pray at the site of a bombing in Ankara in February. (Umit Bektas/AP)

The plea for help came from Sweden: Two young Muslim males had left Stockholm for Syria and would soon be terrorists-in-training unless authorities in Turkey could intercept them.

Turkish security caught the men arriving at an airport in Istanbul with one-way tickets and camouflage gear, officials said. The two were sent back to Sweden and the trouble averted — until eight days later, when the same duo turned up at a Turkish seaport, this time arriving by ferry from the Greek island of Kos.

The back-to-back deportations of those would-be militants last year were in some ways a sign of substantial progress in the cooperation between Western governments and Turkey in sharing intelligence and stemming the flow of foreign fighters to Syria.

But the sequence and hundreds of similar cases have also fueled rising levels of frustration in Turkey, which has been accused of enabling the migration of fighters into Syria even while being called upon to block militants on behalf of other governments unwilling or unable to do the job themselves.

Senior security officials in Turkey described the dynamic with a mix of resignation and resentment, saying that the burden of sharing a long border with Syria has been compounded by other countries’ eagerness to export their Islamist radicals and reluctance to accept refugees.

“Syria is in flames,” Efkan Ala, Turkey’s interior minister, said in an interview. And while dozens of countries have contributed to the conflagration, he said, “they don’t even want the smoke.”

The issues of migrants and foreign fighters will be at the center of a summit in Brussels on Monday between the European Union and Turkey.

Ala’s irritation, which was echoed by officials across Turkey’s security agencies and the Foreign Ministry, reflects the level of friction and fatigue in an effort to constrict the flow of foreign fighters that is only beginning to make headway more than four years after Syria’s civil war began.

Over the past year, Turkey has launched a broad crackdown on militants streaming across its territory. It has deployed undercover surveillance teams at major airports and transit hubs, built new barriers across porous sections of the country’s border with Syria, and given its spy service expanded powers to monitor communications between new arrivals in Turkey and suspected Islamic State facilitators waiting to greet them in Syria.

Turkey has also deepened cooperation with the CIA and other U.S. spy agencies. CIA Director John Brennan has made repeated trips to Ankara, including in January, for meetings on counterterrorism operations. The CIA and its Turkish counterpart, known as MIT, operate a secret coordination center close to the Syrian border.

The CIA-MIT partnership extends beyond work against foreign fighters, according to officials who said the agency flies drones over Syria from the Incirlik air base. CIA officials declined to comment.

U.S. officials said the measures by Turkey have helped reduce the flow of recruits to the Islamic State by as much as one-third, a drop that officials also attribute to the terrorist group’s loss of territory and momentum in Iraq and Syria amid a barrage of coalition airstrikes and offensives by Arab and Kurdish fighters on the ground.

Obama administration officials said Turkey’s new determination in the effort against foreign fighters can be traced to the country’s belated recognition of the danger posed by hard-line Islamist groups including the Islamic State, also known as ISIS or ISIL.

Although Turkey is not suspected of supporting the Islamic State, “they had a ‘hear no evil, see no evil’ approach” to the conflict, said a senior administration official who has been directly involved in counterterrorism talks with Turkey.

“They restrained themselves from going after these rat lines to avoid getting into the crosshairs of ISIL,” the official said, speaking on the condition of anonymity to discuss sensitive security matters. “That bargain expired once bombs started going off in southern Turkey and Istanbul.”

Over the past year, Turkey has endured a series of attacks attributed to the Islamic State, including a suicide bombing in October in the capital city, Ankara, that killed 102 people, and another suicide attack three months later at a historic square in Istanbul that left 10 tourists dead.

U.S. officials frequently describe Turkey as too preoccupied with its decades-long battle with the Kurdish separatist group PKK to devote adequate attention to the Islamic State. But when asked to rank the terrorist threats facing his country, Ala responded with a single word: “Daesh,” an acronym widely used in the region to refer to the Islamic State.

He quickly qualified his answer, saying that the Islamic State and the PKK are “almost at the same level.” But he and others bristled at the suggestion that they were ever blind to the dangers of the Islamic State and noted that they declared it a terrorist group in 2013.

Instead, Ala and other security officials said the effort to sever the Islamic State’s recruiting pipeline began to gain traction only when countries outside the region, especially in Europe, were finally jolted by their own fears into giving up names and data on departing militants that for years they had withheld.

“We started finding people because they started giving phone numbers,” said a senior Turkish security official directly involved in managing the country’s counterterrorism coordination with Europe and the United States. Europe started providing that data, the official said, only after the January 2015 terrorist assault on the offices of Charlie Hebdo magazine in Paris.

Proof of that expanded cooperation, officials said, can be found in the proliferation since of names on Turkey’s terrorism watch list.

The country created the database in 2011 with just 280 entries and by 2014 had nearly 5,000. But over the past year that number has surged to 37,000 on a tidal wave of data turned over by 126 countries.

The list includes names of alleged militants suspected of planning to travel to Syria as well as thousands who have already entered the country and may even have been killed. Officials said that only 123 names in the database correspond to citizens of the United States.

Turkish officials said that while building the database they were frequently dismayed by gaps between the number of foreign fighters nations acknowledged in public and the number of names they had sent to Ankara.

“When the U.K. was talking about 300 foreign fighters, on my list we had only 25 names,” the security official said. Western governments routinely cited privacy restrictions that they said prevented them from turning over data on their own citizens.

The threat of attacks in Europe has prompted nations there to loosen some of those laws and adopt new measures that enable them to detain suspected militants or at least seize their travel documents. But substantial gaps remain.

When asked about the Swedish fighters intercepted by Turkey, officials in Stockholm said they are powerless.

“It is not illegal to travel from Sweden to other countries, even to Iraq and Syria,” said Fredrik Milder, a press officer with Swedish security. “It is not illegal to join ISIS. We have different laws, so I don’t understand what our Turkish colleagues expect.”

Turkish officials described some of the requests from Europe as preposterous. At one point, officials said, Turkey stopped a convoy of three cars carrying French families seeking to join the Islamic State. Rather than retrieve them, officials said, France asked Turkey to assign drivers who would function as chaperones and chauffeurs, reversing the trip in the same three cars.

Confronting such policies, Turkey’s role has come to resemble a paddle on a pinball machine, batting suspected militants away from its borders only to watch more come tumbling toward them across the maps of Europe and the Middle East.

Turkey has deported nearly 3,200 people suspected of ­foreign-fighter-related activities since the war in Syria began, officials said. Another 3,000 are in “returnee centers” awaiting deportation rulings. But those numbers represent only a small fraction of the estimated 35,000 fighters who have traveled to Syria during that period, including 6,600 from Western countries — the vast majority of whom have passed through Turkey.

Beyond screening travelers at airports, bus depots and other points of entry against its burgeoning watch list, Turkey has also ramped up its surveillance and espionage capabilities, in some cases with assistance from the United States.

The nation’s spy chief, Hakan Fidan, secured expanded government authority to carry out NSA-like eavesdropping operations last year — in part by printing copies of U.S. laws to show Turkish courts how U.S. surveillance authorities exceeded his own, officials said.

Fidan also set up a secret unit in MIT known as “Daesh Logistics,” with the task of rooting out the terrorist group’s facilitation networks after mapping those webs through a massive effort to monitor cellphones.

“When a phone moves to a border town, 95­ percent that person is going to Daesh,” a high-ranking Turkish security official said. Islamic State operatives have since reduced the use of phones to evade such scrutiny, officials said, forcing MIT teams to adopt new tactics.

Turkish officials said that the United States was initially reluctant to provide analytic software and other tools to MIT, urging the government to turn over its raw call data and let U.S. spy agencies do the work instead.

Turkish officials said they rejected the request, and that while MIT and Turkish police now take advantage of training and analytic software provided by the United States, the country has not received U.S. surveillance equipment.

Turkey’s record during the crackdown on foreign fighters has been marred by abuses and mistakes. The government has detained journalists and other civilians accused of being fighters seeking to cross the Syria border.

More recently, top officials, including Prime Minister Ahmet Davutoglu, publicly misidentified the suspected bomber in an attack on military personnel that killed 30 people in Ankara last month.

Officials initially identified the bomber as a Syrian fighter affiliated with a Kurdish militia, but they subsequently admitted that he was a Turkish citizen who had entered Syria and then duped authorities by posing as a Syrian refu­gee when he re-entered Turkey in 2014.

The error was only corrected when the bomber’s father, in southeastern Turkey, saw news photos and came to the morgue to identify his son.

Turkish officials believe they recently caught a revealing mistake by their U.S. intelligence counterparts. The two countries have feuded over U.S. and European backing of Kurdish forces in Syria that Turkey sees as subsidiaries of the PKK, the Kurdish group deemed a terrorist organization by the U.S. government.

The United States has refused to extend that label to the groups in Syria, even though Turkish officials pointed to an entry on the website of the U.S. National Counterterrorism Center describing one of the U.S.-backed factions as the PKK’s “Syrian affiliate.” The entry, from a 2014 guidebook, was quickly removed after its existence was noted in Turkish media reports.

Asked why it was taken down, a U.S. intelligence official said, “We update our page periodically to reflect the most accurate assessment of groups and terrorist ­profiles.”

Julie Tate in Washington contributed to this report.

Information sharing

Turkey’s terrorism watch list started with 280 entries in 2011 and has since surged.

5,000 names in 2014

37,000 names in 2016