Turkey has allowed an assemblage of Syrian rebels and their associates, including secular activists, cash-wielding sheiks, arms traffickers and Islamist militants, to use its territory as a transit route, logistics hub and rest stop.

The government has been very clear that it wants to see Syrian President Bashar Assad removed from power. But after more than two years, the conflict is dragging on. Al Qaeda-linked rebel groups are strengthening rapidly in Syria and seizing territory close to the Turkish frontier, the eastern boundary of the NATO alliance.

Increasingly, officials in Ankara, the Turkish capital, as well as critics of the government's policy worry that the militants will establish a permanent presence, exporting extremist ideas and fighters from a chaotic, war-torn state. Despite concern in Washington about the militants' advance, Turkey appears to have few good options.

"Ankara's calculation has been that Assad has to go, and Turkey will allow anyone who wants to fight Assad to go into Syria," said Soner Cagaptay, an analyst with the Washington Institute for Near East Policy. "To Turkey it didn't matter that much if there were some bad guys, because once Assad was gone the good guys would take over and clean out the bad guys."

Now that calculus is changing. "Turkey is realizing that Assad may not go," Cagaptay said. "And the good guys may not take over."

Turkish artillery batteries opened fire last month on positions in Syria of a powerful Al Qaeda-linked rebel faction, the Islamic State of Iraq and Syria, after its fighters captured the Syrian town of Azaz, just three miles from the border. Turkey shut the crossing to Azaz, prompting an Internet threat by the group to extend a campaign of car bombings to Turkish soil.

Turkey could be more cautious about which Syrian opposition groups receive aid and who can operate in the border region. Officials are pushing back against charges that Turkish territory has become a launch pad for Al Qaeda-linked groups such as Al Nusra Front. News reports have cited seizures of trucks carrying what they described as suspicious chemicals and warheads for hundreds of rockets.

But sealing the frontier zone to Syrian rebel factions would choke off supply routes and could lead to the collapse of the entire anti-Assad rebellion in Syria's north.

Alarmed by the downward spiral, Turkey has launched something of a diplomatic offensive with neighbors, including Iran, a key backer of the Assad government. Iran's foreign minister, Mohammad Javad Zarif, visited Ankara early this month and the two nations vowed to work together to find a solution for Syria, despite being on opposite sides of a proxy war there.

When an armed rebellion first surfaced against the autocratic Assad in 2011, Turkish officials embraced a vigorous policy of backing the opposition on the assumption that Assad's government was on the verge of collapse. Assad's exit would have opened the way for Turkey's grateful clients to seize power in Damascus.

But it hasn't worked out that way, with Assad clinging to power as the West, and most specifically the Obama administration, opted not to provide robust military aid to the Syrian opposition.

Turkish Prime Minister Recep Tayyip Erdogan, architect of Ankara's Syria policy, did not hide his displeasure when the recent U.S.-Russian-brokered deal to neutralize Syria's chemical weapons seemed to rule out the prospect of an American bombing campaign against Syria.

Erdogan rejects the idea that Islamic militant groups could gain a foothold in Turkey. "It is out of the question that organizations like Al Qaeda or Al Nusra could take shelter in our country," he said Thursday on a visit to Sweden.

But his policy of providing a welcome mat for Syrian rebels of all stripes is drawing the ire of many Turks who fear that long-secular Turkey is being dragged into Syria's increasingly sectarian quagmire.

"Why are we bringing in all these crazies here?" asked Suleyman Osterek, an opposition politician in Antakya, another border-area town that has seen an influx of Syrian fighters. "These people scare us."

In an interview this monthwith Britain's Guardian newspaper, Turkish President Abdullah Gul voiced concern that Syria could become "something like Afghanistan on the shores of the Mediterranean."

It is unclear whetheradditional Western military support or even direct U.S. intervention would have pushed Assad out or just accelerated the process of militarization and radicalization in Syria. Afghanistan in the 1980s, Iraq after the 2003 U.S.-led invasion and current-day Libya all provide examples of Islamist militants gaining traction after the West-backed toppling of authoritarian governments.

Today, fractious opposition brigades and sundry warlords hold sway over vast stretches of Syria. The Islamic State of Iraq and Syria and another Islamist offshoot, Al Nusra Front, both apparently bankrolled by wealthy donors in the Persian Gulf and elsewhere, now count among insurgent Syria's major power brokers, and by some accounts are the most dominant.

The Islamic State has drawn thousands of recruits from other rebel units and throngs of eager volunteers from dozens of nations. Turkey is now widely regarded as a transit route for Syria-bound Islamist militants from the Persian Gulf, North Africa, Europe and Chechnya and elsewhere. Iraqi, Jordanian and Lebanese volunteers usually enter via their nations' borders with Syria, experts say.

With extremists in the ascendance, the U.S.-backed policy of aiding "moderate" rebel groups appears to face major hurdles.

The numbers of foreign Islamist militants in Syria now exceed those who previously flocked to Iraq and Afghanistan, according to U.S. congressional estimates. There is widespread concern in the West that the Syrian conflict is incubating a new generation of extremists who could eventually wreak havoc across the globe.

"When it is over, these people will be combat trained, combat hardened, and they are going to want to go home," U.S. Rep. Mike Rogers (R-Mich.), chairman of the House Intelligence Committee, said last month.

As Turkey grapples with the Islamist militants on its doorstep, it also faces the emergence in northern Syria of autonomy-minded Kurdish militiamen allied with the Kurdistan Workers Party. Turkey has battled the party for more than 30 years, though peace talks are now underway.

Secular Kurdish militiamen, who have long viewed the radical Islamist forces as their archenemy, have proved to be the sole Syrian faction capable of pushing back the onslaught. Late last month, Kurdish militiamen overran a crossing along the Iraqi border, expelling Al Qaeda-affiliated fighters.

The volatile border tableau has prompted speculation that Ankara could eventually seek a strategic alliance with Syrian Kurds. Though improbable on one level, it no longer seems out of the question, analysts say.

"Turkey is going to have to make some very, very difficult decisions, given the way Syria has unraveled," said Howard Eissenstat, a Turkey expert at St. Lawrence University in New York. "They are backing up, recalibrating and saying, 'OK, what is our long game going to look like?'"