AMMAN (Reuters) - Jordan said on Thursday that Israel had formally apologized for the deaths of two of its citizens killed by an Israeli security guard last July in an incident that soured ties and led to the closure of the Israeli embassy in Amman, state media said.

Slideshow ( 2 images )

Government spokesman Mohammad al Momani was quoted by state news agency Petra as saying the Israeli foreign ministry had sent a memorandum expressing “deep regrets and apologies” over the incident at the embassy and pledging to take legal action in the case.

Jordan had said it would not allow Israel to reopen its embassy in Amman until it launched legal proceedings against the security guard.

The Israeli prime minister’s office said on Thursday that the embassy in Amman would resume full operations immediately.

The handling of the shooting had tested ties between Israel and Jordan, one of only two Arab states that has a peace treaty with Israel. The two have a long history of close security ties.

The embassy was closed shortly after Israel hastily repatriated the guard under diplomatic immunity to prevent Jordanian authorities interrogating him and taking any legal action against him. The Israeli ambassador and embassy staff were pulled out.

Jordan maintained that even if the guard had diplomatic immunity that did not mean he could not be punished.

Israel has now pledged to “implement and follow up legal measures” in the case and also take action in the shooting of an unarmed Jordanian judge by an Israeli soldier in an incident in 2014, Momani said.

Israel would pay compensation to the three families, he said.

Israel said at the time the armed guard opened fire after being attacked and lightly wounded by the workman, who was delivering furniture at his home within the embassy compound, and acted in self-defense in what Israeli officials called a “terrorist attack”.

Israel then said it was highly unlikely it would prosecute the security guard.

Jordanian officials have treated the shooting as a criminal case and say the two unarmed Jordanians - the other was a bystander - were killed in cold blood by the armed guard.

The government statement said the Israeli government had met all of Jordan’s demands for the return of the ambassador and the reopening of the embassy.

Many Jordanians, in a country where the peace treaty with Israel is unpopular and pro-Palestinian sentiment widespread, were outraged that the guard was allowed to leave and staged protests calling on the authorities to scrap the 1994 peace treaty.

A televised welcome home for the guard and a hero’s embrace from Israeli Prime Minister Benjamin Netanyahu had enraged King Abdullah. In a rare outburst, he accused Netanyahu of using the incident as a “political show” saying it was “provocative on all fronts”.