Rifai Ahmed Taha, wearing a white prayer cap in this photo believed to have been taken in Turkey in 2015, lived under Turkish protection before being killed in a U.S. drone strike in April. Also in the photo, second from the right, is Mohammad Shawqi al-Islambouli, whom U.S. officials believe has ties to al-Qaeda-allied groups in Syria. (Long War Journal/Foundation for Defense of Democracies)

To his Turkish hosts, Rifai Ahmed Taha was a tiny, elf-like man with an oversize beard and colorful past. To U.S. officials, he was a dangerous terrorist who would be tracked and targeted — if ever he left his Turkish sanctuary.

The opportunity came in early April, when Taha ventured across the border into Syria for a meeting with Islamist militants. Just five days later, a U.S. drone fired a missile at the Egyptian’s car as it stopped for gas near the Syrian city of Idlib, killing him and four other suspected jihadists.

The strike ended the career of a man who had been an ally of ­Osama bin Laden and, more recently, an adviser to Syrian rebels linked to al-Qaeda. It also highlighted what U.S. terrorism experts view as Turkish schizophrenia when it comes to battling violent jihadists: Even as Turkey ramps up its campaign against the Islamic State, it continues to tolerate and even protect other Islamists designated by Western governments as terrorists.

Turkey has defended its policy of giving refuge to exiled supporters of Egypt’s Muslim Brotherhood government, which was overthrown in a coup in 2013. But among those offered shelter in Turkey are leaders of the Egyptian group Gamaa Islamiya, , whose members carried out murderous attacks against tourists in Egypt in the 1990s and were later tied to multiple plots to kill Americans.

Like Taha, some of the exiles continued to support pro-al-

Qaeda groups in Syria , U.S. officials say. Taha was trying to mediate a dispute between Jabhat al-Nusra — al-Qaeda’s Syrian affiliate — and another Islamist faction when he was killed.

“These people were part of [al-Qaeda leader Ayman] al-Zawahiri’s core cadre,” said Jonathan Schanzer, a former Treasury Department counterterrorism official and now vice president for research at the Foundation for Defense of Democracies, a Washington think tank. “It’s all the more troubling because Turkey is a NATO member that is supposed to be allied with the West in fighting a common enemy.”

[After attacks, ISIS and Turkey drift toward outright war]

The new concerns about Turkey’s protection of violent jihadists follow years of complaints about Ankara’s support for other Islamist groups, such as Hamas. While the Palestinian group’s military wing is officially listed by the United States as a terrorist organization, Turkey has repeatedly granted asylum to Hamas operatives, and it allowed the group to open an international headquarters in Istanbul two years ago.

Since 2013, Turkey has served as a refuge and organizing base for exiled opponents of Egyptian President Abdel Fatah al-Sissi’s government. Istanbul is home to thousands of Muslim Brotherhood activists — the vast majority of them nonviolent — as well as at least two Web TV channels that specialize in anti-Sissi programming, including explicit calls for the overthrow of Egypt’s secular government.

Such permissive policies stand in contrast to Turkish President Recep Tayyip Erdogan’s newly assertive stance against the Islamic State, the group suspected in last month’s Istanbul airport attack that killed 45 people. Erdogan has moved to tighten lax border controls that allowed terrorist recruits and contraband to flow from Turkey into Iraq and Syria, and last week he vowed a further crackdown against a group that he called “not Islamic.”

“Taking one person’s life means going straight to hell,” he said in remarks after the airport attack.

Yet Erdogan has taken a softer line toward Jabhat al-Nusra, one of several Islamist groups that Turkish officials supported during the early years of the Syrian civil war before formally breaking with it under Western pressure in 2014. In a speech last month, Erdogan repeated his suggestion that the “terrorist” label was inappropriate for Jabhat al-Nusra’s Islamist rebels, who, after all, also are at war with the Islamic State.

Turkish officials reject criticism of the country’s policies as hypocritical. Western countries, including the United States, are providing weapons and money to Kurdish groups that Turkey regards as terrorist, noted a senior Turkish diplomat, who spoke on the condition of anonymity to discuss a policy dispute with a NATO ally.

“The difference is, Turkey doesn’t give arms or training to any of these groups,” the official said. “We’re concerned over U.S. engagement with [Kurdish militia group] YPG. The United States justifies its support for them because they’re fighting ISIS. But to us, this support is very destructive to the stability of the region.”

A jihadist elder statesman

The Egyptian exile killed in the April 5 drone strike was undeniably deserving of the terrorist label, according to U.S. counterterrorism officials familiar with his history.

Taha was 61 and wizened, with a broad, snow-white beard, when he crossed into Syria for a meeting with Islamist rebel groups. Yet U.S. officials contend that even at that age, he was an active and respected figure within al-Qaeda’s network in the Middle East and beyond. He had been wanted by Washington since the late 1990s, when U.S. prosecutors named him as a co-conspirator in al-Qaeda plots to strike U.S. targets around the world.

Taha had been a senior leader in Egypt’s Gamaa Islamiya in 1997 when its members killed 58 foreign tourists and four Egyptian guides in Luxor, Egypt. In later years, by his own admission, he would participate in multiple plots to assassinate Egyptian leaders, and he would publicly praise al-Qaeda’s attack on the USS Cole in Yemen in 2000. While Gamaa Islamiya would ultimately renounce terrorism, Taha was part of a small faction that continued to sanction its use, a State Department report concluded in 2001. The report described Taha’s faction as committed to “attacks against U.S. and Israeli interests.”

[Istanbul attacks are the latest blow to Turkey’s sagging tourism industry]

Taha, also known as Rifai Taha Musa, was arrested in Syria in late 2001 and deported to Egypt, where he spent the next decade in prison. But he regained his freedom, along with hundreds of other jailed Islamists, after the 2011 election that brought Muslim Brotherhood leader Mohamed Morsi to power.

Morsi’s overthrow and arrest two years later sent hundreds of supporters fleeing to Turkey, to be welcomed by an Erdogan government that publicly condemned the coup and denounced Egypt’s new president as a despot. But among the exiles were a number of veteran jihadists well-known to Western counterterrorism officials, including Taha and Mohammad Shawqi al-Islambouli, also a former top leader of Gamaa Islamiya, which is also known as the Islamic Group.

Islambouli, who announced his official status as a protected political refu­gee on his Facebook account in June 2015, was a close bin Laden ally in the 1980s and 1990s. His alleged continued association with jihadist groups prompted U.S. Treasury officials in 2005 to label him a “specially designated global terrorist.” Last year, a special review of Islambouli’s record by U.N. officials resulted in the removal of his name from the world body’s terrorist list. The United States kept him on its list. Efforts to reach Islambouli for comment were unsuccessful.

Since at least 2014, U.S. officials have linked Taha and Islambouli to the Khorasan Group, an al-Qaeda offshoot in Syria said to specialize in planning attacks against the West. Yet during this time, the two lived openly in Istanbul, appearing at conferences and media events. Taha was an occasional guest on pro-Morsi Web TV channels, where he would sometimes encourage fellow Egyptians to take up arms against their country’s government.

“What are we waiting for?” he asked during a November 2014 interview recorded in Istanbul. “We will not confront this regime with bare chests. If they take up arms, then we will take up arms.”

[Why airport attacks are nearly impossible to defend against]

Associates of Taha confirmed that he was killed while trying to settle a dispute between Jabhat al-Nusra and other Islamist factions in Syria. His death was mourned at a public service in Istanbul, attended by friends and former comrades, including Islambouli, according to photos and videos taken at the event.

‘What he wished for’

It was a fitting end for a career jihadist who had always talked of becoming a martyr, according to Hani al-Sibai, director of the Maqrizi Center for Historical Studies in London. Taha had no sooner crossed into Syria than he “got what he wished for,” Sibai said.

“He met his Lord in an American drone strike,” Sibai said.

Turkey’s embrace of exiles such as Taha and Islambouli has drawn condemnations from Egypt’s government, which has blasted Erdogan as a terrorist supporter who is contributing to instability in the Middle East. Erdogan, for his part, insists that he rejects terrorism and seeks only to protect Muslims’ right to peaceful self-determination.

“If we defend democracy, then let’s respect the ballot box,” Erdogan said in a 2014 U.N. speech, in a thinly veiled critique of Egypt’s Sissi.

Yet the violent histories of some of Turkey’s “guests” undercut such claims, highlighting the perils of a policy that seeks to protect and even encourage some extremists while Turkey wages war against others, according to U.S. officials and analysts.

[ISIS shows it can still inspire violence abroad despite setbacks at home]

Erdogan’s governing Justice and Development Party, or AK Party, party aligns itself with the international Muslim Brotherhood movement, and Erdogan personally has sought to project himself as a defender of oppressed Islamists, from Cairo to the Palestinian territories. But in reality, the lines between ardent nationalism and violent extremism are never neatly drawn, said Soner Cagaptay, director of the Turkish Research Program at the Washington Institute for Near East Policy, a think tank.

“The AKP is Muslim Brotherhood-lite,” Cagaptay said. “But even as a ‘lite’ version, it is internationally networked and sympathetic to the heavier version. And that includes Hamas and the Egyptian Muslim Brotherhood.”

Turkish officials have maintained that they can control such groups by allowing them to operate in the open. But Ankara once made similar claims about radical Syrian factions that it allowed to work in relative freedom along the border, noted Schanzer, the former Treasury official.

“The Turks turned a blind eye, and now they’re paying the price,” Schanzer said. “The idea was that they could distinguish between these groups — between a guy from the Egyptian Islamic Group or al-Nusra Front and another from the Islamic State. But they don’t really have the ability to distinguish, and now they’ve lost their way.”

Read more:

How Obama went from reluctant warrior to drone champion

Inside the Caliphate: Gruesome scenes from an ISIS prison in Fallujah

In tiny Albania, worries about the emergence of ISIS