Prodded by President Obama, Israel and Turkey agreed Friday to end a three-year rift caused by a deadly Israeli commando raid on a Turkish ship bound for Gaza, a rapprochement urgently sought by the United States to help contain spillover from the worsening fighting in Syria.

During an airport meeting with Obama at the end of his two-day visit to Israel, Prime Minister Benjamin Netanyahu phoned Turkish Prime Minister Recep Tayyip Erdogan, Israeli and U.S. officials said.

Bowing to a long-standing Turkish demand, Netanyahu apologized for the deaths of nine activists aboard the Turkish ship and promised to reach an agreement on compensation to their families, according to a statement from his spokesman.

The Israeli and Turkish leaders agreed to restore normal relations, including the return of ambassadors and the cancellation of Turkish legal proceedings against four former senior Israeli army commanders accused of involvement in the raid, Israeli officials said.

Concerned about the deterioriating situation in Syria, the Obama administration has been trying to mend relations between its allies Turkey and Israel, two regional powers on Syria’s borders.

“The United States deeply values our close partnerships with both Turkey and Israel, and we attach great importance to the restoration of positive relations between them in order to advance regional peace and security,” Obama said in a statement.

“I am hopeful that today’s exchange between the two leaders will enable them to engage in deeper cooperation on this and a range of other challenges and opportunities,” the president added.

A senior administration official who briefed reporters traveling with Obama said the president got on the line with the Israeli and Turkish leaders and suggested they “talk more in detail in the near future.”

Speaking later in Jordan, Obama said that he had pushed the two leaders for months to repair the rupture in their relationship but that during his visit to Israel, “it appeared that the timing was good” for them to talk. But he also sought to temper expectations about the renewed relations.

“This is a work in progress,” Obama said. “It’s just beginning. As I said, there are obviously going to still be some significant disagreements between Turkey and Israel — not just on the Palestinian question, but on a range of different issues.”

A senior Israeli official said that while Israel and Turkey had come close in the past to an understanding to restore ties, Friday’s agreement was spurred by the Syrian conflict.

The official said the new understanding was like “a newborn baby” that needed nurturing. “I hope this will provide an opening to a different relationship,” he said.

Ties between Israel and Turkey deteriorated after the May 2010 Israeli raid on the Turkish ship, Mavi Marmara, which was part of an aid flotilla headed for the Gaza Strip. Israeli commandos who boarded the vessel in international waters opened fire after meeting violent resistance from activists on deck, killing eight Turks and an American of Turkish descent.

The flotilla was organized by international activists to challenge Israel’s naval blockade of the Gaza Strip, which is governed by the militant Islamist group Hamas.

Turkey expelled the Israeli ambassador in Ankara and downgraded its diplomatic and military relations with Israel in September 2011 in anger at Israel’s refusal to apologize for the flotilla killings. Netanyahu reversed that position Friday.

In his conversation with Erdogan, Netanyahu “made clear that the tragic outcome of the Mavi Marmara incident was not intended by Israel, and that Israel regrets the loss of human life and injury,” his spokesman said.

“In light of the Israeli investigation into the incident, which pointed to a number of operational mistakes, Prime Minister Netanyahu expressed Israel’s apology to the Turkish people for any mistakes that might have led to loss of life or injury, and agreed to conclude an agreement on compensation,” the spokesman added.

In apparent reference to the situation in Syria, the spokesman said Netanyahu told Erdogan that he had talked with Obama about “regional cooperation and the importance of Israel-Turkey relations.”

A statement from Erdogan’s office said he accepted Netanyahu’s apology “on behalf of the Turkish people.” It added that Erdogan expressed regret over the recent worsening of their ties, “which he sees as having vital strategic importance for the peace and stability of the region.”

Netanyahu also told Erdogan that he appreciated the Turkish leader’s recent statement to a Danish newspaper in which he qualified his public reference last month to Zionism as “a crime against humanity,” equating it with anti-Semitism, fascism and Islamophobia, the Israeli statement said.

In a nod to Turkey’s demand that Israel remove restrictions on movement in and out of the Gaza Strip, Netanyahu said that Israel had “substantially lifted” some curbs on movement of civilians and goods to the Palestinian territories and that this would continue as long as the situation remained calm.

Israel halted the shipment of goods to Gaza on Thursday and tightened fishing limits off the Gaza coast after a rocket fired from the territory hit the southern Israeli city of Sderot.

Aaron Stein, a researcher at the Istanbul-based Center for Economics and Foreign Policy Studies, said that “both sides were looking for a way to crawl down from their hard-line positions” and that “Syria gave them the political cover to meet halfway.”

“On Syria, both sides have the incentive to cooperate, especially on preventing the spread of chemical weapons to non-state actors,” such as Kurdish separatists in Turkey or the Iranian-backed Hezbollah group facing Israel across the Lebanese border, Stein said.

Soli Ozel, an international relations professor at Istanbul’s Kadir Has University, said normalized relations between Israel and Turkey would free them to cooperate on intelligence sharing and containing a possible spillover of the fighting in Syria.

“Syria is very much at the center of this,” he said.

Wilson reported from Amman. Justin Vela in Istanbul contributed to this report.