CAIRO – Egypt registered an official complaint with Israel Friday over the deaths of five of its soldiers in fighting after an ambush targeting Israelis near the border between the two countries as tensions spiked between the two formerly staunch allies.

Retaliatory violence between Israel and the Islamic militant group Hamas also escalated Friday in the aftermath of the deadliest attack against Israelis in three years. Israeli airstrikes killed at least 12 Palestinians, most of them militants, in the Gaza Strip, and six Israelis were wounded when Palestinians fired rockets into southern Israel.

Egypt’s official news agency blamed an Israeli fighter jet for shooting and killing four Egyptian soldiers and one policeman while chasing militants who killed eight Israelis in Thursday’s ambush in southern Israel.

An Israeli military officer said a suicide bomber, not Israeli soldiers, killed the Egyptian security forces. He said the attacker had fled back across the border into Egypt and detonated his explosives among the Egyptian troops. He spoke on condition of anonymity according to military regulations. Israeli media reported that some of the sniper fire directed at the Israeli motorists Thursday came from near Egyptian army posts and speculated that the Egyptian troops were killed in the cross fire.

It was not possible to reconcile the different versions.

“There was an exchange of fire between Israeli soldiers and terrorists on the Egyptian border following the deadly terror attack Thursday morning. We are investigating this matter thoroughly and will update the Egyptians,” the Israeli military said.

Thursday’s attack signaled a new danger for Israel from its border with the Sinai Peninsula, an area that has always been restive but was kept largely under control by former Egyptian leader Hosni Mubarak. The desert area has become increasingly lawless since Mubarak was ousted on Feb. 11 after a popular uprising.

The violence also threatened to further damage ties between the two countries if Egypt’s political upheaval and a resulting power vacuum in Sinai allows Gaza militants, who had been pummeled by a punishing Israeli three-week war 21/2 years ago, to open a new front against Israel in the frontier area.

Relations between the two countries have been chilly since they made peace in 1979, but Israel valued Mubarak as a source of stability with shared interests in containing Iran and its radical Islamic proxies in the region.

Anger rose after Egyptian officials said Thursday’s gunbattles killed five Egyptian security personnel. An Egyptian security official said three died Thursday and two others died of wounds on Friday.

Egyptian protesters staged demonstrations after Friday prayers in front of the Israeli Embassy in Cairo, and politicians echoed the populist line.

“Israel and any other (country) must understand that the day our sons get killed without a strong and an appropriate response, is gone and will not come back,” wrote Amr Moussa, former Arab League chief and now a presidential hopeful. He tweeted his statement along with, “the blood of our martyrs which was spilled while carrying out their duties, will not be shed in vain.”

Gunmen crossed the border from Egypt on Thursday and set up an ambush along a 300-yard strip, armed with automatic weapons, grenades and suicide bomb belts, the Israeli military said.