It is said that Benjamin Franklin once quoted "The enemy of my enemy is my friend". This is a dangerous position to take, because one cannot assume that the enemy of your enemy will not turn against you. The U.S. made a huge mistake when it befriended Saddam Hussein in Saddam's early years when the Ayatollah Khomeini was at war with the U.S. Saddam was armed with advanced U.S. fighter jets and his army was given military training. We all know how it ended. Saddam Hussein eventually waged war against the Kurds, the Sunni's, Kuwaitis, and eventually the West. One must never assume that the enemy of an enemy is automatically a friend.
Some years ago the prevailing sentiment was that certain countries should take in political refugees who are fighting against regimes not friendly to themselves. This is unwise. For example, a jihad fighter believes that it is his religious duty to eliminate all non-Muslims. Should a non-Muslim government readily grant such a person asylum if he is a political refugee in his own country? In this case, certainly, the enemy of your enemy can potentially also be your enemy!