The clashes erupted when a group of local fighters on Tuesday morning countered a sudden Israeli incursion in the area.

However, the Israeli military said troops spotted fighters trying to plant explosives near a crossing between Gaza and Israel and opened fire on them with tanks and helicopters. The military said it believed four militants were killed, and they were armed with explosives, grenades and assault rifles.

The military released a photograph of the weapons it said were found.

Gaza medics said only two bodies were retrieved. The reason for the discrepancy was not clear.

The fighting highlighted Hamas difficulties in preventing smaller rivals from carrying out attacks against Israeli targets. One of those rivals, Islamic Jihad, was involved in Tuesday's fighting.

Hamas has been trying to maintain the truce since Israel's devastating Gaza offensive more than a year ago, while its rivals are pushing for renewed attacks.

A senior Hamas leader later said that his group is trying to preserve the cease-fire, in part to avoid giving Israel a reason for a new offensive. “There was a meeting between the factions, and there was consensus between Hamas and factions that at this time, there should not be anything to provoke the enemy to conduct a new war on Gaza,” said Moussa Abu Marzouk, a Hamas leader living in Damascus.

Israel launched the Gaza war in response to years of rocket fire from Gaza on Israeli border towns. Since the war, Hamas fighters have not claimed responsibility for firing rockets, though fighters from smaller groups do so sporadically.