In recent years, President Obama, his European friends, and even some Middle Eastern allies, have supported “rebel groups” in Libya and Syria. Some received training, financial and military support to overthrow Muammar Gadhafi and battle Bashar al Assad. It’s a strategy that follows the old saying, “The enemy of my enemy is my friend,” and it has been the American and allied approach for decades in deciding whether to support opposition groups and movements.

The problem is that it is completely unreliable — and often far worse than other strategies. Every year there are more cases in which this approach backfires. The most glaring and famous failure was in Afghanistan, where some of the groups taught (and supplied) to fight the Soviet Army later became stridently anti-Western. In that environment, Al Qaeda flourished and established the camps where perpetrators of the Sept. 11, 2001, attacks were trained. Yet instead of learning from its mistakes, the United States keeps making them.

Washington and its allies empowered groups whose members had either begun with anti-American or anti-Western views or found themselves lured to those ideas in the process of fighting. According to interviews with members of militant groups, such as the Islamic State in Iraq and Syria’s Al Nusra Front (which is aligned with al Qaeda), that is exactly what happened with some of the fighters in Libya and even with factions of the Free Syrian Army.

“In the East of Syria, there is no Free Syrian Army any longer. All Free Syrian Army people [there] have joined the Islamic State,” says Abu Yusaf, a high-level security commander of the Islamic State, whom The Washington Post’s Anthony Faiola wrote about last week.

The Islamic State is the most successful group for now, controlling the main areas of Syrian oil and gas fields. It has also acquired large amounts of cash, gold (from banks in the areas they control) and weapons in its fight against the armies in Syria and Iraq. “When the Iraqi Army fled from Mosul and the other areas, they left behind all the good equipment the Americans had given them,” Abu Yusaf says.

“From IS to the Mahdi army you see groups that basically are not our friends but who became more powerful because we have handled the situations wrong,” says a senior U.S. security official, who spoke under the condition of anonymity.

Some European and Arab intelligence officials also voiced their worries and frustration about what they call the mistakes the United States has made in handling the uprisings in Arab states. “We had, in the early stages, information that radical groups had used the vacuum of the Arab Spring, and that some of the people the U.S. and their allies had trained to fight for ‘democracy’ in Libya and Syria had a jihadist agenda — already or later, [when they] joined al Nusra or the Islamic State,” a senior Arab intelligence official said in a recent interview. He said that often his U.S. counterparts would say things like, “We know you are right, but our president in Washington and his advisers don’t believe that.” Those groups, say Western security officials, are threats not only in the Middle East, but also in the United States and Europe, where they have members and sympathizers.

The official’s account has been corroborated by members of the Islamic State in and outside the Middle East, including Abu Yusaf, the military commander. In several interviews conducted in the last two months, they described how the collapse of security during Arab Spring uprisings helped them recruit, regroup and use the Western strategy — to support and train groups that fight dictators — for their own benefits. “There had [also] been … some British and Americans who had trained us during the Arab Spring times in Libya,” said a man who calls himself Abu Saleh and who only agreed to be interviewed if his real identity remained secret.

Abu Saleh, who is originally from a town close to Benghazi, said he and a group of other Libyans received training and support in their country from French, British, and American military and intelligence personnel — before they joined the Al Nusra Front or the Islamic State. Western and Arab military sources interviewed for this article, confirmed Abu Saleh’s account that “training” and “equipment” were given to rebels in Libya during the fight against the Gadhafi regime.

Abu Saleh left Libya in 2012 for Turkey and then crossed into Syria. “First I fought under what people call the ‘Free Syrian Army’ but then switched to Al Nusra. And I have already decided I will join the Islamic State when my wounds are healed,” the 28-year-old said from a hospital in Turkey, where he is receiving medical treatment. He had been injured during a battle with the Syrian Army, he said, and was brought to Turkey with false documents. “Some of the Syrian people who they trained have joined the Islamic State and others jabhat al Nusra,” he said, smiling. He added, “Sometimes I joke around and say that I am a fighter made by America.”

For a long time, Western and Arab states supported the Free Syrian Army not only with training but also with weapons and other materiel. The Islamic State commander, Abu Yusaf, added that members of the Free Syrian Army who had received training — from the United States, Turkey and Arab military officers at an American base in Southern Turkey — have now joined the Islamic State. “Now many of the FSA people who the West has trained are actually joining us,” he said, smiling.

These militants are preparing for the day that Western governments catch on. “We do know the U.S. will go after the Islamic State at some stage, and we are ready for it. But they should not underestimate the answer they will get,” said an IS sympathizer in Europe who goes by the name Abu Farouk. He added that the “unconditional support” of the United States toward the government of outgoing premier Nuri al-Maliki, which he says has oppressed Iraqi Sunnis, and America’s “pampering Iran,” which is mainly Shia, made the Islamic State a more attractive alternative for some Sunnis who felt angry about double standards.

“Thanks to the Arab spring and the West fighting all these rulers for us, we had enough time to grow and recruit in the Middle East, Europe and the U.S,” Abu Farouk said. Then he paused for some seconds and smiled. “Actually, we should say, thank you, Mr. President.”

Souad MekhennetSouad Mekhennet is a correspondent on the national security desk. She is the author of "I Was Told to Come Alone: My Journey Behind the Lines of Jihad," and she has reported on terrorism for the New York Times, the International Herald Tribune and NPR. Follow