Bedouin mourners take part in a funeral for Saleh Abu Latif, 22, in Rahat, Israel. Latif, an Israeli security fence worker, was killed from a Palestinian sniper's fire as he was mending the Israel - Gaza border fence. (Uriel Sinai/Getty Images)

It was a legitimate target, the masked militant said later, an irresistible target. An Israeli was repairing a section of the fence that surrounds the Gaza Strip. A decision was made: Shoot him.

The sniper attack in late December, ordered by a faction of Palestinian militants in Gaza, triggered an immediate retaliatory air and tank assault by Israel that killed not a terrorist but a toddler, and wounded three others.

The two deaths, which were news for just a few hours in Israel and Gaza, are part of a deadly exchange of messages — between armed groups in Gaza that want to demonstrate that their resistance to Israel continues and the Israel Defense Forces, which insist that every assault from Gaza must be answered.

Officially, a 14-month-old cease-fire between the Islamist militant group Hamas, which controls the Gaza Strip, and its enemy, Israel, is holding. Unofficially, it is a truce that grows more tense by the day as Hamas struggles to rein in armed factions that are not completely under its control. This kind of escalation has led to two wars in the past five years, and there is a palpable sense today that another could be on the horizon.

Israeli Defense Minister Moshe Yaalon warned recently: “If Hamas doesn’t know how to impose its authority on terrorist organizations operating from its territory,” it will “pay a heavy price.”

Rocket fire from Gaza toward Israel is increasing; there were 28 launched in January, according to the Israeli military. So are Israeli strikes and armed incursions into the coastal enclave. Israel carried out at least two targeted killings against Gaza militants last month, killing two people and wounding one.

Hamas is facing isolation and economic hardship, and its leaders say they need to maintain the truce. Egypt’s new military-led government has shut down many smuggling tunnels from that country into Gaza, which provide tax revenue for Hamas. Whereas Hamas has the responsibility to run the schools, pay municipal salaries and keep the electricity on, smaller armed factions have one overriding goal: to fight Israel.

‘We don’t care who he is’

The Nasser Salah al-Deen Brigade, whose sniper shot the Israeli fence worker, answers to the Popular Resistance Committees, which the United States considers a terrorist organization. The group opposes negotiation and any security cooperation with Israel, and it is one of a half-dozen armed factions in Gaza capable of launching rockets.

According to Abu Saed, a masked spokesman for the brigade who spoke at a house outside Gaza City on the condition that his full name not be used, the sniper rushed into position after the Israeli worker was spotted. Then he fired.

The victim was Saleh Shukri Abu Latyef, 22, a Muslim and Bedouin from the Israeli town of Rahat. He worked for a private contracting firm hired by the Israeli military, and it was his first time working at the Gaza fence, a relative said. He died two hours after he started.

“It is not easy to lose such a young person. He was the flower of his family,” said his cousin, Ribhi Abu Latyef.

“We are a peaceful family, and we don’t blame anyone,” he said. “We believe in two states for two peoples, a country where Palestinians can govern themselves and a country where Israelis are not being attacked.”

Asked whether they felt any remorse for killing a fellow Muslim, the spokesman for the brigade said, “We don’t care who he is. He was working with the Israeli army.”

Armed escalation

Everyone in Gaza knew there would be a reprisal.

Armed factions in Gaza say the skies above their heads are buzzing with more Israeli F-16s, Apache helicopters and drones than usual.

“Something big is coming,” said a spokesman for the military wing of the group Islamic Jihad, who goes by the nom de guerre Abu Ahmed. “But we don’t know what.”

Israel and Hamas are wary of where the current escalation is taking them. The two sides fought an eight-day war in late 2012 that saw missiles fired from Gaza reach the outskirts of Tel Aviv and a punishing aerial campaign by Israel. The fighting killed 174 Palestinians, more than half of them noncombatants, and six Israelis, four of them civilians, according to a review of the conflict by the United Nations.

Since the cease-fire, 52 rockets fired from Gaza have landed in Israel, according to the Israeli Foreign Ministry. No injuries have been reported.

Israeli defense officials acknowledge that Hamas is not the source of the rocket fire. But because Hamas has governed Gaza since 2006, Israel holds it accountable.

Retaliatory fire kills girl

On the afternoon that the Gaza sniper killed the Israeli contractor, Israeli aircraft, tanks and infantry retaliated.

“Direct hits were confirmed,” the military announced. The target list included “a terror infrastructure site” near the fence in central Gaza.

That site was the house where Hala Abu Sbaikha, 2, lived. She was playing in the yard when she was struck in the neck by a piece of shrapnel from a tank artillery shell, her relatives said.

Her aunt, Bothina Abu Sbaikha, was wounded. She said that her niece died in a taxi en route to the hospital.

An uncle knelt down on a recent day and blew leaf litter away to show a dried pool of blood soaked into the earth. Asked whether militants had used the house as a terrorist site, Sbaikha insisted no.

“This was our home,” she said. “Nothing else.”

‘Hard’ task for Hamas

According to the Al Mezan Center for Human Rights in Gaza City, 19 Gaza residents, including two children, have been killed by Israeli strikes since the cease-fire, and more than 170 have been wounded. The number includes militants, protesters who got too close to the fence, and innocent bystanders — the latter of whom Hamas calls martyrs and the Israelis describe as human shields.

As Hamas finds itself in the unlikely role of enforcing the cease-fire, it is struggling to keep the more aggressive factions from launching attacks, though Hamas is careful not to condemn them publicly.

“The Israelis know Hamas is expending a huge effort to maintain the cease-fire. We have hundreds of our police watching and trying to prevent rocket fire,” said Basem Naim, a foreign affairs adviser to Ismail Haniyeh, the Hamas prime minister.

Hamas security forces have detained and interrogated members of rival groups in efforts to stop rocket fire, according to spokesmen for those factions. Last month, Hamas called a meeting of leaders of the strip’s five main armed factions and reinforced that the truce needed to be kept, according to Gaza-based political scientist Mkhaimar Abusada.

Mahmoud al-Zahar, a founder of Hamas, said the Israelis “understand that Hamas has control of the situation, and that the alternative to Hamas would be chaos — with fanatics coming in from the outside, creating a new Sinai, a new Syria, in Gaza.”

“This is hard for Hamas. . . . This effort costs them, costs them time, credibility, their reputation for resistance,” said Omar Shaban, an economist at a Gaza think tank.

“But Hamas is helped by the fact that launching rockets is not very popular among the people in Gaza,” he said. “We are not stupid. We know firing rockets is not working.”

Hazem Balousha in Gaza and Ruth Eglash in Jerusalem contributed to this report.