Is Israel trying to help Hamas? Is Jerusalem trying to undermine its strategic position in the Middle East?

One can't help asking such questions after Israel's botched attack on a civilian aid flotilla bound for Gaza, which killed several Turkish citizens. Who but Hamas could benefit from an Israeli military raid on an international convoy that was clearly not running guns?

The most troubling question: Did Israeli officials never consider the consequences of attacking a Turkish vessel with Turkish nationals aboard? Yes, some pro-Palestinian Turkish militants were present. But was this strike worth deep-sixing Israel's already strained relationship with Turkey - historically its closest ally in the Muslim world?

Turkey recognized Israel in 1949 and still buys weapons from the Jewish state. The Turkish armed forces train with their Israeli counterparts (although Ankara just canceled upcoming exercises). Hundreds of thousands of Israeli tourists visit Turkey every year.

Some argue that Turkey's relations with Israel have been sliding downhill since the 2003 ascendancy of Prime Minister Recep Tayyip Erdogan, whose Justice and Development Party has Islamist roots. Aware that its chances for admission to the European Union are minimal, Turkey is seeking a much larger role in the Mideast, which includes its (somewhat naive) efforts to mediate between Iran and the West and bring Hamas to peace talks.

However, Israel's relations with Turkey didn't shrivel with Erdogan's rise; he visited Israel in 2005, and President Shimon Peres was invited to speak to Turkey's Grand National Assembly in November 2007 - the first time an Israeli leader addressed a Muslim parliament.

The relationship really began to deteriorate after Israel launched a military operation in Gaza in December 2008. The Turkish leader, an emotional man, saw this attack as a personal betrayal.

The reason: Erdogan had met with Israel's then-prime minister, Ehud Olmert, in Ankara only three days before the Gaza operation to discuss Turkey's very active mediation between Israel and Syria. But Olmert never alerted Erdogan to the imminent Israeli invasion of Gaza, which caused the Turkish leader enormous political embarrassment at home. The Israeli strike also froze Turkey's mediation efforts with Syria.

In meetings I attended at the Davos World Economic Forum in January 2009, Erdogan also claimed that before the Gaza strike, Turkey had been making headway in negotiations to free Israeli soldier Gilad Shalit, a prisoner of Hamas.

The Turkish leader clearly viewed the Gaza attack as a repudiation of his mediation efforts. "I saw this as a lack of respect for us," he told journalists. This personal pique came through in a very public, onstage spat between Erdogan and Peres at Davos.

The Turkish premier was also furious that, due to Israel's refusal to allow the entry of certain kinds of aid, including building materials, into Gaza, Turkey could not help rebuild the Gaza infrastructure destroyed in the 2008 strike. In an interview in New York in September 2009, Erdogan told me angrily: "This construction is still not allowed [by Israel]. Turkey is not allowed to build schools, houses, hospitals. The Israelis allow food and medicine to pass, but not the rest."

Erdogan also complained that, while the world rushed to help Georgia rebuild after the 2008 Russian invasion, there was no similar humanitarian push to rebuild Gaza after Israel's military attack.

So it should have come as no surprise that Turkey refused Israel's request that it try to halt the private aid flotilla to Gaza. Over the past year, Erdogan had repeatedly lashed out at Israel in public, and Israeli officials returned the favor. Lost in the emotional repartee was the danger of letting a strategic relationship go to hell.

This destructive cycle can only lead to grief. Turkey's parliament has asked Erdogan to review ties with Israel; Turkey might even send armed escorts with another aid flotilla.

It's time for cooler heads, including President Obama, to salvage what remains of the relationship between Jerusalem and Ankara. Turkey is still a key NATO ally, and its importance in the region is growing. Erdogan should not be left by default to the embraces of Hamas and Iran.

For starters, Obama should urge Israel to apologize for the Turkish casualties and drop an aid blockade around Gaza that only strengthens Hamas. Yes, guns must be blocked, but there's surely a way to let Turkish cement into Gaza while ensuring it's used to rebuild hospitals, not bunkers. Otherwise, Turkey and Israel could yet come to blows.

Trudy Rubin can be reached at trubin@phillynews.com.