When he took office in May, Turkey's prime minister declared it was time for the country to put its international affairs in order and reclaim its place as an oasis of stability in a war-torn region. Turkey was trying to do just that — mending fences with both Israel and Russia only this week — when suicide bombers hit its main airport, throwing those plans into disarray.

Tuesday's gun-and-bomb attacks killed more than 40 people, including at least 10 foreigners, and highlighted Turkey's precarious position on the borders of Syria and Iraq. Just a day earlier, Turkey and Israel had announced a deal ending six years of acrimony, and Turkey had expressed regret to Russia over its downing of a warplane, paving the way for reconciliation with Moscow.

Prime Minister Binali Yildirim pinned the airport attack on the Islamic State group, which is battling an array of enemies in Iraq and Syria including Western powers and Russia.

"It is meaningful that this heinous attack came at a time when we have become successful in the fight against separatist terrorism... and at a time when we started a process of normalizing ties with our neighbors," Yildirim said.

Sabah newspaper, which is close to the government, called the attack a "treacherous ambush on peace," saying it came as Turkey was spearheading peace initiatives that would "change regional balances." 

While any direct link between the attack and Turkey's reconciliation efforts is uncertain, there is no doubt that it has a destabilizing effect on a country where a renewed conflict with Kurdish separatists and a spate of attacks by the IS group have kept tourists and investments away. Turkey's crackdown on dissenting voices and media freedoms has also hurt its international standing.

Giray Sadik of Ankara's Yildirim Beyazit University said such attacks are usually pre-planned, making any connection to Monday's normalization moves unlikely. But, he said, "it will harm Turkey's image. It came at a time when (Turkey) was hoping that the rapprochement with Russia would revive its tourism industry."

The charm offensive with Israel and Russia follows several years of foreign policy bungles that crippled Turkey's influence in the region and left it with few friends.

Relations between Israel and Turkey began to decline after President Recep Tayyip Erdogan, whose party has Islamist roots, became prime minister in 2003 and got even worse when he criticized Israeli operations against Palestinians. They reached an all-time low over Israel's 2010 raid against a Turkish ship aiming to breech the blockade of Gaza. Nine Turks, including a dual American citizen, were killed. Another later died of his wounds.

This week's agreement with Israel will now lead to an exchange of ambassadors, a revival of economic ties and new energy deals.

The same day that deal was announced, Erdogan sent a letter to Russian President Vladimir Putin expressing regret over an incident seven months ago where Turkey shot down a Russian jet on a mission in Syria, triggering a slew of Russian sanctions that have dealt a blow to the Turkish economy. In a sign of warming ties, the two leaders talked by phone Wednesday and agreed to meet face-to-face during a G-20 summit in China.

In the Syrian conflict, Turkey has been accused of supporting Jihadist groups in a bid to bring about Syrian President Bashar Assad's ouster, a move critics say helped exacerbate the civil war and cause the refugee crisis. Turkey, which has taken in some 3 million Syrian refugees, strongly rejects the accusation.

Turkey also has turbulent relations with the European Union over the implementation of a deal to stem the flow of migrants and is frustrated with the United States over its support of a Syrian Kurdish militia. The latter plays a key role in the U.S. fight against IS in Syria, but Turkey considers it a terror organization because of its affiliation with Turkey's Kurdish rebels.

Svante Cornell, Director of the Central Asia-Caucasus Institute and Silk Road Studies Program, said the airport attack is an indication of how difficult it will be for Turkey to clean up years of foreign policy failures.

"Turkey inserted itself in the affairs of the Middle East, threw its support behind non-governmental armed groups, taking sides in various conflicts without seriously considering the consequences," Cornell said. "If you use these kinds of groups they have a tendency to turn back and bite and Turkey is now paying the price for its decisions."