Turkish Prime Minister Recep Tayyip Erdogan (Umit Bektas / Courtesy Reuters)

After nearly three years of intense political feuding following the Israeli raid on the Mavi Marmara -- a ship carrying international activists who were trying to break Israel’s blockade on Gaza -- Turkey and Israel agreed yesterday to resume diplomatic ties. In a phone call with Turkish Prime Minister Recep Tayyip Erdogan, Israeli Prime Minister Benjamin Netanyahu apologized for the deaths of nine Turkish citizens at the hands of Israeli forces and agreed to pay compensation. In return, Erdogan agreed to normalize relations between the two countries and to drop the prosecutions of Israeli officers in connection with the flotilla raid. Turkey had previously demanded that, in addition to apologizing and paying compensation, Israel lift the blockade. In order to get around this last -- and thorniest -- condition, Netanyahu stressed that Israel has recently eased restrictions on civilian goods coming into Gaza, and he agreed to work with Turkey on improving the humanitarian situation there. The details of the arrangement still need to be worked out, but it appears that the two countries are well on their way to resuming cooperation in a number of areas.

It has been clear for some time that Israel was willing to make an apology to Turkey, but less clear whether Turkey would accept it. Now that election season is over in Israel, Netanyahu no longer has to worry about nationalist criticism over repairing ties with Turkey, and the temporary exclusion of former Foreign Minister Avigdor Lieberman from the cabinet removed the biggest obstacle to reconciliation on the Israeli side. But the politics in Turkey are a different story. The Palestinian issue has made Israel deeply unpopular there, and the feud has been politically valuable for Erdogan, who has been able to blast Israel any time he has wanted to divert attention away from sensitive domestic issues. Last month, for example, Turkish headlines were dominated by the government’s negotiations with Abdullah Ocalan, the leader of the separatist Kurdistan Workers’ Party (PKK). When Erdogan publically called Zionism a crime against humanity, he chased the talks right off the front pages.

Given these domestic political benefits, Ankara has had little reason to reconcile with Israel until now. This week’s news, however, signals that Turkey has finally come to realize that it has more to lose than to gain from turning a cold shoulder to Israel. This is largely because Turkey can use Israel’s help on its most pressing foreign policy dilemma, the Syrian civil war, and on its top economic concern, energy security.

For Ankara, the Syrian crisis has been a major headache. Turkey has suffered a loss in trade, been forced to rely on NATO for Patriot missiles to defend against border threats, and accepted just under half a million Syrian refugees. Ankara’s demands for Assad to step down have fallen on deaf ears, and its requests for NATO intervention in the form of a no-fly zone and heavy arms for the Syrian rebels have also been brushed aside.

All this has been unfortunate for Turkey’s leaders, but it was the recent introduction of Syrian chemical weapons into the equation that really changed Turkey’s calculus; now more than ever, the country needs better intelligence and allies to bring an end to the civil war or at least prevent it from spilling over. Turkey cannot afford to have chemical weapons used anywhere near its border with Syria, and the longer the fighting goes on, the greater the chances of a chemical weapons strike gone awry. Israel simply has better intelligence on regional developments than Turkey does, and Turkey can use that help to monitor Assad’s weapons stores and troop movements on both sides. In addition, whereas the United States and other NATO countries have been reluctant to support the Syrian rebels in any meaningful way, Israel has a greater incentive to make sure that the moderate Sunni groups prevail over the more radical jihadist elements of the opposition. As the situation in Syria heats up, Turkey and Israel will be thankful that they can talk to each other and coordinate.

Another area in which Turkey needs Israel’s assistance is energy. Turkey’s current account deficit, which stood at $48.8 billion in 2012, is almost entirely a result of the country’s reliance on oil and natural gas imports; Turkey has no natural resources of its own. Furthermore, Turkey is paying through the nose for both Russian and Iranian natural gas, due to onerous price contracts. Earlier this month, I talked with a number of people in Turkey -- government ministers, opposition politicians, business tycoons, and trade group leaders -- and they all mentioned Turkey’s growing energy needs and lamented the country’s overreliance on Russian and Iranian natural gas. Israel, meanwhile, has just discovered two major natural gas basins, the Tamar and Leviathan fields, off its coast in the Eastern Mediterranean. Since Turkey has no hope of smoothing over ties with Cyprus, its longtime adversary, which has been the other main beneficiary of the Mediterranean gas boom, it will likely turn to Israel as a natural gas supplier. With Turkey’s economic growth slowing, Israel’s potential as a partner makes reconciliation more attractive now than at any point in recent years.

Other factors also made this week the ideal timing for Turkey to accept an Israeli apology. For starters, doing so during President Barack Obama’s trip to the region allowed Erdogan to hand the president a political victory. At the same time, Erdogan gets to claim that he brought Israel to its knees just as Turkish nationalists were gearing up to criticize him over negotiating with Ocalan and taking a softer line with the Turkish Kurds. A significant segment of the Turkish population still denies that there is a Kurdish problem and sees any government effort toward easing tensions as capitulating to terrorists. Following Ocalan’s speech on Thursday, which signaled a genuine break from the past by transforming the PKK’s fight against Turkey into a political struggle rather than an armed struggle, Erdogan now has both the political space to resume ties with Israel and the ability to spin the rapprochement with Israel as a nationalist victory in which Israel has ceded to Turkish demands.

Squabbling with Israel had its benefits for Erdogan, but with so many challenges facing Turkey, and with Obama pressuring both sides to make up, the time was finally right to do so. For the first time since the Mavi Marmara set sail, the economic and foreign policy gains that Turkey will realize by patching things up with Israel far outweigh the domestic political benefits of staying apart. Sometimes, a reliable friend is better than a reliable adversary.