By Nidal al-Mughrabi and Ari Rabinovitch
GAZA/JERUSALEM (Reuters) - A surge in deadly violence in the Gaza Strip and southern Israel petered out overnight with Palestinian officials reporting that Egypt had mediated a ceasefire on Monday ending the most serious spate of cross-border clashes for months.
The latest round of fighting erupted three days ago, peaking on Sunday when rockets and missiles from Gaza killed four civilians in Israel. Israeli strikes killed 21 Palestinians, more than half of them civilians, over the weekend.
Two Palestinian officials and a TV station belonging to Hamas, Gaza's Islamist rulers, said a truce had been reached at 0430 a.m. (0130 GMT), apparently preventing the violence from broadening into a conflict neither side seemed keen on fighting.
Israel did not formally confirm the existence of a truce with Hamas and its allied Gaza faction Islamic Jihad, militants that it, like much of the West, designates as terrorists.
Officials in Prime Minister Benjamin Netanyahu's government spoke in more general terms of a reciprocal return to quiet, with one suggesting that Israel's arch-enemy Iran - a major funder for Islamic Jihad - had been behind the Gaza escalation.
Suffering under renewed U.S. sanctions and Israeli strikes against its military assets in Syria, Iran may have seen stoking Palestinian violence as a way of telling Israel, "we will get back at you through (Islamic) Jihad and Gaza", Israeli Energy Minister Yuval Steinitz told the Israeli radio station 90 FM.
Israel's military said that more than 600 rockets and other projectiles - over 150 of them intercepted - had been fired at southern Israeli cities and villages since Friday. It said it shelled or carried out air strikes on some 320 militant sites.
The violence abated before dawn, just as Gazans were preparing to begin the Muslim holy month of Ramadan.
Rocket sirens in southern Israel, which had gone off continuously over the weekend, sending residents running for cover, did not sound on Monday and there were no reports of new air strikes in Gaza.
Egypt and the United Nations, who have served as brokers in the past, had been trying to mediate a ceasefire.
The violence began when a sniper from the Palestinian militant group Islamic Jihad fired across Gaza's fenced border at Israeli troops on routine patrol, wounding two soldiers, according to the Israeli military.
Islamic Jihad accused Israel of delaying implementation of previous understandings brokered by Egypt in an effort to end violence and ease the economic hardships of blockaded Gaza.
This time both Islamic Jihad and Hamas appeared to see some leverage to press for concessions from Israel, where annual independence day celebrations begin on Wednesday and with the Eurovision song contest due to kick off in Tel Aviv - the target of a Gaza rocket attack in March - next week.
Some 2 million Palestinians live in Gaza, the economy of which has suffered years of Israeli and Egyptian blockades as well as recent foreign aid cuts and sanctions by the Palestinian Authority, Hamas' West Bank-based rival.
Israel says its blockade is necessary to stop arms reaching Hamas, with which it has fought three wars since the group seized control of Gaza in 2007, two years after Israel withdrew its settlers and troops from the small coastal enclave.
One of Islamic Jihad's leaders in Gaza said on Sunday that the group was trying to counter efforts by the United States to revive peace negotiations between Israel and the Palestinians.
U.S. President Donald Trump's Middle East team has said it will unveil its peace plan in June, after Ramadan is over. Peace negotiations have been moribund since 2014.
"What the resistance is doing now is the most important part of confronting Trump's deal. We all have to get united behind the decision by the resistance to fight," Islamic Jihad's Jamil Eleyan said in a statement.
Israeli military spokesman Lieutenant-Colonel Jonathan Conricus said that over the past few weeks Islamic Jihad had been trying to perpetrate attacks against Israel in order to destabilize the border. "This isn't some local initiative, it is part of a strategic choice to escalate matters," Conricus said.
During the eight-year civil war in Syria, Iran's military has built a presence there backing President Bashar al-Assad.
Israel regards Iran as its biggest threat and has vowed to stop it from entrenching itself in Syria, its neighbor to the north, repeatedly bombing Iranian targets in Syria and those of allied Lebanese Hezbollah militia.
Trump's national security adviser John Bolton said on Sunday the administration was deploying a carrier strike group and bombers to the Middle East in response to troubling "indications and warnings" from Iran and to show the United States will retaliate with "unrelenting force" to any attack.
(Additional reporting by Dan Williams and Maayan Lubell in Jerusalem; Writing by Maayan Lubell; Editing by Mark Heinrich)