“Shame on you!” tweeted Ibrahim Kalin, adviser to Turkish President Recep Tayyip Erdogan, on Monday. Kalin condemned the killing of Palestinians in Gaza and contrasted it with the “singing and celebrating” as the US moved its embassy to Jerusalem. “The world shares this shame in its silence.”Hours later, the Israeli ambassador to Turkey was notified that Ankara intended to expel him. Turkey lowered its flags to half-staff to commemorate those killed in Gaza, and two political parties sought to annul agreements with Israel and impose economic sanctions. It is the latest spat in a long, historic and tumultuous relationship. Turkey was the first Muslim country to recognize Israel, in 1949, and the states enjoyed relatively warm relations for many decades. Turkey and Israel shared many interests in the region as allies of the West and modern, relatively secular countries in a region dominated by Arab nationalism and rising religious extremism.The 1990s and early 2000s were the peak of the relationship, with military and economic relations growing. A memorial for slain Ottoman soldiers was built in Beersheba and a statue of Ataturk, the founder of modern Turkey, unveiled. A massive delegation of Turkish businesspeople visited Israel in 2007. Kurdish protesters even attacked the Israeli Embassy in Berlin in 1999, accusing Israel of playing a role in the Turkish capture of Kurdistan Workers Party leader Abdullah Ocalan.Initially under Erdogan and the rise of his Justice and Development Party (AKP) in 2002, relations continued to be warm. Erdogan visited Israel, condemned antisemitism and sought to play a role in an Israel-Syrian peace agreement.Turkey also sought to help with Israeli-Palestinian peace initiatives, and both Shimon Peres and Mahmoud Abbas visited Turkey. Erdogan told The Washington Post in 2009 that Israel should engage Hamas: “Hamas is not an arm of Iran. Hamas entered the [Palestinian] elections as a political party. If the whole world had given them the chance of becoming a political player, maybe they would not be in a situation like this after the elections that they won [in January 2006].”TURKEY WAS seeking to broker a Syria-Israel deal and was disgusted when prime minister Ehud Olmert visited Ankara and then returned to Israel and launched Operation Cast Lead against Hamas in Gaza.In January 2009, Erdogan walked off stage at the World Economic Forum in Davos, Switzerland, after comments by then president Peres. Cast Lead destroyed confidence in Israel among the leadership of the AKP, and relations have never recovered.In May 2010, a flotilla led by the Turkish Mavi Marmara passenger ship and manned by members of the Turkish Foundation for Human Rights and Freedoms and Humanitarian Aid (IHH) sought to break the blockade of Gaza. A raid by Israel Navy commandos led to the deaths of 10 Turkish citizens in a melee on deck. Turkey withdrew its ambassador and accused Israel of a “bloody massacre” aboard the ship. Joint military exercises were canceled.Then in 2016, Prime Minister Benjamin Netanyahu and Turkish Prime Minister Binali Yildirim patched up relations to a degree, with Israel agreeing to pay $20 million to Turkey for those slain on the Marmara. Economic relations were a backdrop to the deal.Israel was discussing exporting natural gas to Turkey, and in 2017, Energy Minister Yuval Steinitz was in discussions with his Turkish counterpart about a pipeline deal.Israel was also reported to be buying oil from the Turkish port of Ceyhan. The Financial Times wrote that this included oil shipped from the Kurdish autonomous region in northern Iraq.The backdrop to the recent anger at Israel by Ankara is not just the protests in Gaza. In the lead-up to the Kurdish referendum in Iraq in September, Turkish politicians objected to the flying of Israeli flags by Kurds in northern Iraq. In December, when President Donald Trump announced that the US was recognizing Jerusalem as Israel’s capital, Turkey hosted a meeting of the Organization of the Islamic Conference to condemn the move. Erdogan condemned Israel as a “terror state.”When the Gaza protests broke out on March 30 and more than a dozen Palestinians were killed, the Turkish president called it a “massacre.” Netanyahu responded with harsh criticism of Turkey’s actions in Syria, where Turkey had been fighting the Kurdish People’s Protection Units, a group Ankara views as terrorists. “Anyone who occupies northern Cyprus, invades the Kurdish strip and slaughters citizens in Afrin should not lecture us,” Netanyahu said.It came as no surprise when Erdogan tweeted on Tuesday that Hamas “is not a terrorist organization,” writing that it was a “resistance movement that defends the Palestinian homeland against an occupying power.” Perhaps more surprising was that the People’s Democratic Party (HDP) and the Republican People’s Party (CHP) sought to annul the 2016 agreement with Israel, and the CHP sought to have Turkey’s ambassador permanently withdrawn.The AKP opposed canceling the agreement, but Prime Minister Yildirim said Muslim countries should review their ties with Israel.Commentator Serkan Demirtas, writing at Hurriyet, noted that ties might be ruined.THERE ARE several layers to the current war of words between Ankara and Jerusalem. First is the embassy and Jerusalem issue.Turkey supports the Palestinians’ demand for Jerusalem as their capital.Turkey also uses the Organization of the Islamic Conference to garner Islamic support regarding the Jerusalem issue. And Ankara is outraged by the deaths in Gaza.The AKP has long been supportive of Hamas, arguing that it is a legitimate political organization.But this support has put Turkey at odds with other countries because Turkey was also supportive of the Muslim Brotherhood contesting elections in Egypt. This is part of a wider struggle where Turkey and Qatar embraced the Muslim Brotherhood in the early 2000s. But other countries in the region, such as Saudi Arabia, the United Arab Emirates and Egypt, have come to oppose the Brotherhood, and they are critical of Hamas.Turkey’s problems with Jerusalem therefore are threefold.Religious anger over Jerusalem, empathy with Palestinians in general, support for Mahmud Abbas politically, support for Hamas as well as support for humanitarian aid to Gaza and regional anger that Riyadh, Abu Dhabi and Cairo appear to be closer politically to Israel. This is ironic since Turkey has diplomatic and trade relations with Israel while Riyadh and Abu Dhabi do not.But nothing is as black and white as it seems. Qatar has been supporting Gaza financially via Israel and views Israel as a key to its continued ability to work in the Strip. US presidential envoy Jason Greenblatt was in Doha on Wednesday meeting with Qatar’s Foreign Minister Sheikh Muhammad Bin Abdulrahman al-Thani and discussing Gaza.The AKP’s decision to oppose canceling the 2016 agreement is tied to the desire by Ankara, which is close to Doha, to continue to play a role in aiding the Palestinians rather than ruin relations with Israel, since all these relationships are intertwined.That is dependent on Jerusalem’s decisions as well.Anger at Turkey’s decision to expel the Israeli ambassador and rhetoric from Turkey will encourage Israel to speak out about the Kurds and other issues. With Turkey planning an Organization of the Islamic Conference meeting and rallies at the end of the week, and campaign electioneering taking place in Turkey, relations could sour more.