The latest clashes began when militants crossed into southern Israel and killed eight Israelis on Thursday.
Subsequent Israeli air strikes on Gaza killed 15 Palestinians. One Israeli was killed in rocket fire from Gaza.
The Quartet of Middle East peace mediators - the UN, US, EU and Russia - has called for restraint.Informal truce
A Palestinian official said that Hamas had agreed to ensure that the ceasefire was recognised by smaller militant groups in Gaza - which were responsible for most of the rockets fired at southern Israel in the past few days.
Prior to the announcement, Israeli media reported that 12 rockets launched from the Gaza Strip landed in southern Israel overnight. No injuries resulted.
But on Monday, Gaza's Popular Resistance Committees (PRC) - last to agree to the truce - agreed to halt rocket fire against Israel as a "temporary" measure "for the sake of the Palestinian people".
Earlier, Israel's army radio reported that Israeli Prime Minister Benjamin Netanyahu's security cabinet had decided the military would stop its air strikes on Gaza if militants there halted their attacks.
Like similar arrangements in the past this is not a formal agreement, says the BBC's Yolande Knell in Jerusalem.
Tensions in and around Gaza have risen rapidly since Thursday's deadly shooting attacks in the Negev desert, when Palestinian gunmen shot dead eight Israelis near the Red Sea resort town of Eilat.
Seven of the attackers and five Egyptian security personnel were killed as Israeli troops pursued the gunmen.
Israel also launched a wave of retaliatory air strikes against the PRC, killing 15 people in the Gaza Strip - including the leader of the PRC and several other militants. Civilians were also among the dead.
Meanwhile, Palestinian militants fired more than 100 rockets and mortars into Israel, killing one man in Beersheba and injuring dozens.
Thursday's incident has also led to a diplomatic dispute between Israel and Egypt. Cairo has called the killing of its five soldiers "unacceptable" and warned that it could recall its ambassador from Israel.
Israel said it "regretted" the deaths of the five Egyptians.