Image copyright Reuters Image caption The Mavi Marmara was the lead ship in a six-vessel aid convoy

Israel and Turkey have announced an agreement to end an acrimonious, six-year diplomatic rift.

The two countries were close allies, but relations broke down after the killing by Israeli commandos of 10 Turkish activists on board a ship that was part of an aid flotilla attempting to breach the blockade of Gaza on 31 May 2010.

How did the confrontation begin?

The six ships in the flotilla were boarded in international waters, about 130km (80 miles) from the Israeli coast. Commandos landed on the largest ship, the Turkish-owned Mavi Marmara, by descending on ropes from helicopters. Clashes broke out immediately and the Israeli commandos opened fire.

Who started the violence?

This is disputed. The activists say the commandos started shooting as soon as they hit the deck. Israeli officials say the commandos opened fire only after being attacked with clubs, knives and a gun which was taken from them. Video released by the Israeli military stops just before the shooting begins. A UN inquiry was apparently unable to determine at exactly which point the commandos used live fire.

Where were the dead activists from?

They were all Turkish, although one had dual Turkish-US nationality. All were travelling on the Mavi Marmara.

What was the purpose of the flotilla?

It wanted to deliver aid to Gaza, breaking an Israeli and Egyptian blockade on the territory. The ships were carrying 10,000 tonnes of goods, including school supplies, building materials and two large electricity generators. The activists also said they wanted to make the point that, in their view, the blockade was illegal under international law.

Who organised it?

Gaza Movement, an umbrella organisation for activists from numerous countries, and a Turkish group called the Foundation for Human Rights and Freedoms and Humanitarian Aid (IHH).

The Israeli government says the IHH is closely linked to the Palestinian Islamist movement Hamas, which it views as a terrorist group, and is a member of another organisation, the Union of the Good, which supports suicide bombings. However, the Turkish government regards the IHH as a legitimate charity, and had urged Israel to let the flotilla through.

Why did Israel want to stop the flotilla?

Israel prevents a large range of goods from reaching Gaza in order to put pressure on Hamas, which dominates the territory.

Israel also wanted to check that the ships did not contain deliveries of weapons or cash. It offered to allow the flotilla to land in an Israeli port, and to deliver by road any goods that passed its checks.

Some flotillas have been allowed to reach Gaza in the past; others have been sent back.

How did the international community react?

There was widespread condemnation of the violence. The UN Security Council issued a statement calling for a "prompt, impartial, credible and transparent" inquiry.

UN Secretary General Ban Ki-moon urged Israel to lift the Gaza blockade.

What have the various inquiries found?

In September 2010, a UN Human Rights Council report said Israel's military broke international laws, that the action by commandos, which left nine dead, was "disproportionate" and "betrayed an unacceptable level of brutality". Israel rejected the report as "biased" and "one-sided".

Image copyright AFP Image caption The UN panel said the loss of life from the use of force by Israeli troops was "unacceptable"

Israel and Turkey held their own inquiries, submitting the findings to an international panel set up by the UN, chaired by a former New Zealand Prime Minister, Sir Geoffrey Palmer, and including an Israeli member and Turkish member.

Turkey's report, drawn up by government officials, accused Israeli commandos of "excessive, brutal and pre-meditated" conduct. It concluded their action boarding the Mavi Marmara was "unlawful" and breached human rights. Results of post-mortem examinations had earlier suggested a total of 30 bullets were found in the bodies of the dead activists, including one who had been shot four times in the head. The Turkish panel also deemed the Gaza blockade "unlawful".

The Israeli inquiry, headed by Judge Jacob Turkel, and including five Israeli members and two international observers, found the actions of the navy and Israel's blockade of Gaza were legal under international law. However, it offered some criticism of the planning of the military operation. It also referred to "the regrettable consequences of the loss of human life and physical injuries".

In September 2011, the UN panel concluded in a repeatedly-delayed report that the loss of life and injuries resulting from the use of force by Israeli troops was "unacceptable".

"Israel's decision to board the vessels with such substantial force at a great distance from the blockade zone and with no final warning immediately prior to the boarding was excessive and unreasonable," it said.

Image copyright Reuters Image caption The Israeli commandos faced "significant, organised and violent resistance", the UN said

However, the commandos did face "significant, organised and violent resistance", requiring them to "use force for their own protection", the panel found.

Nevertheless, no satisfactory explanation was provided by Israel for any of the deaths, and the "forensic evidence showing that most of the deceased were shot multiple times, including in the back, or at close range" was not accounted for, the report said.

There was also "significant mistreatment" of passengers by Israeli authorities after the takeover of the vessels, including physical mistreatment, harassment and intimidation, unjustified confiscation of belongings and the denial of timely consular assistance, it added.

At the same time, the panel said that the Israeli naval blockade on Gaza was imposed as a "legitimate security measure" to prevent weapons from entering Gaza by sea and its implementation complied with the requirements of international law. The flotilla acted "recklessly" in attempting to breach the naval blockade of Gaza, and more could have been done to warn flotilla participants of the potential risks involved and to dissuade them from their actions, according to the report.

In November 2014, a preliminary examination by the International Criminal Court's Chief Prosecutor concluded that it should not take further action despite a "reasonable basis to believe that war crimes… were committed", because it had to prioritise war crimes on a larger scale.

How were relations between Turkey and Israel affected?

The flotilla incident caused a deep rift between the former allies.

In the immediate aftermath of the flotilla raid, Turkey withdrew its ambassador from Tel Aviv and then Prime Minister Recep Tayyip Erdogan called for Israel to be punished for its "bloody massacre". Joint military exercises were also cancelled.

Following the publication of the Palmer report, which was delayed several times as diplomats tried to repair relations, Turkey expelled the Israeli ambassador in Ankara.

"The time has come for Israel to pay for its stance that sees it as above international laws and disregards human conscience," Foreign Minister Ahmet Davutoglu said. "The first and foremost result is that Israel is going to be devoid of Turkey's friendship."

The Turkish government had insisted on receiving an Israeli apology by the time the report was released.

Israeli officials noted that the UN report did not demand a full apology, establishing only that Israel should issue an "appropriate statement of regret" and "offer payment for the benefit of the deceased and injured victims and their families".

"Israel, like any other country, has a legitimate right to protect its citizens and soldiers," an Israeli government official told the BBC.

In November 2012, a court in Istanbul began trying in absentia four retired Israeli commanders over the raid. Among the charges was "inciting murder through cruelty or torture".

The accused were named as Israel's former military chief of staff, Gen Gabi Ashkenazi, former naval chief Vice-Admiral Eliezer Marom, former head of military intelligence Maj Gen Amos Yadlin, and former head of the air force Brig Gen Avishai Lev.

The Israeli embassy in Ankara called the trial a "unilateral political act with no judicial credibility".

How was the dispute resolved?

In March 2013, Israel and Turkey's prime ministers unexpectedly agreed to restore normalise diplomatic relations and end the legal action against former Israeli commanders.

The breakthrough came after Israeli Prime Minister Benjamin Netanyahu spoke to Mr Erdogan in a telephone conversation brokered by US President Barack Obama during a visit to Israel.

A statement from Mr Netanyahu's office said he had "made it clear that the tragic results regarding the Mavi Marmara were unintentional and that Israel expresses regret over injuries and loss of life".

"In light of the Israeli investigation into the incident, which pointed out several operational errors, Prime Minister Netanyahu apologized to the Turkish people for any errors that could have led to loss of life and agreed to complete the agreement on compensation," it added.

Mr Erdogan, who became Turkey's president the following year, said they had also "agreed on making arrangements for compensation" to the victims' families, adding that he had "accepted the apology in the name of the Turkish people".

In June 2016, Turkey and Israel agreed to normalise their relations.

Officials said the reconciliation deal would see Israel pay $20m in compensation to the families of those killed on the Mavi Marmara; Turkey allowed to deliver aid to Gaza via an Israeli port; and Turkish infrastructure projects aimed at improving the humanitarian situation in the Palestinian territory.

In return, Turkey agreed to pass legislation protecting Israeli troops from legal claims, and to prevent any military action or fundraising by Hamas operatives based there.