* Ceasefire to begin 8 a.m. (0500 GMT)
* Longer-term truce to be discussed in Cairo
* Israeli troops to remain in place during truce
GAZA/JERUSALEM - Israel and Palestinian militant groups in the Gaza Strip have agreed to a three-day humanitarian truce to begin Friday morning, and negotiators from both sides will travel to Cairo to discuss a longer-term solution.
The 72-hour break after more than three weeks of fighting was set to begin at 8 a.m. (0500 GMT), according to a joint statement released by U.S. Secretary of State John Kerry and U.N. Secretary-General Ban Ki-moon.
An official in Prime Minister Benjamin Netanyahu's office said Israel had accepted the U.S./U.N. proposal. A spokesman for Hamas, the Islamist group dominant in Gaza, said all Palestinian factions would abide by the truce.
"We urge all parties to act with restraint until this humanitarian ceasefire begins, and to fully abide by their commitments during the ceasefire," Kerry and Ban said. "This ceasefire is critical to giving innocent civilians a much-needed reprieve from violence."
Hours before the ceasefire was announced, Netanyahu, facing international alarm over a rising civilian death toll in Gaza, said he would not accept any truce that stopped Israel from completing the destruction of militants' infiltration tunnels.
According to the Kerry and Ban statement, forces on the ground would remain in place during the ceasefire.
Israel and Palestinian delegations in the meantime will travel to Cairo for separate negotiations to reach a more durable ceasefire, the statement said.
The Palestinian delegation will be comprised of Hamas, Western-backed Fatah, the Islamic Jihad militant group and a number of smaller factions, Palestinian officials said.
A senior U.S. State Department official said talks could start as early as Friday, depending on how long it takes the parties to reach Cairo. Representatives from Israel and the United States will not sit across the table from Hamas, the official added.
The United States, European Union and Israel consider Hamas a terrorist group.
Egypt's Foreign Ministry said it "stresses the importance the two sides respect their obligations resulting from their announcement of ceasefire so that negotiation can be held in suitable condition and achieve the desired results."
Fighting continued, however, overnight. Hamas said it fired rockets at Israel, setting off air raid sirens in the area of Tel Aviv. Israel's military said its Iron Dome defense system intercepted one of the rockets. Residents of Gaza reported further Israeli shelling.
Previous international attempts to broker a humanitarian truce were less successful, securing shorter periods of calm, some of which collapsed immediately after being announced.
U.N. political affairs chief Jeffrey Feltman said it took a massive diplomatic push to achieve the ceasefire.
"The Egyptians played an important role, the Qataris played an essential role in helping bring the parties on board, the Turks were in touch with all sides. This was a collective effort," Feltman told CNN.
Israel launched its offensive in Gaza on July 8 in response to a surge of cross-border rocket attacks.
Gaza officials say at least 1,427 Palestinians, most of them civilians, have been killed in the battered territory and nearly 7,000 wounded. Fifty-six Israeli soldiers have been killed in the fighting and more than 400 wounded. Three civilians have been killed by Palestinian shelling in Israel.
Netanyahu faces intense pressure from abroad to stand his forces down. The United States and the U.N. Security Council have urged both sides to halt fighting in Gaza to allow in humanitarian relief.
Israel has ordered its ground forces to focus on locating and destroying a warren of tunnels through which Hamas has menaced its southern towns and army bases.
"Our understanding is that the Israelis will make clear to the U.N. where their lines are, roughly, and they will continue to do operations to destroy tunnels that pose a threat to Israeli territory that lead from the Gaza strip into Israel proper as long as those tunnels exist on the Israel side of their lines," said the State Department official.
With Israeli forces remaining on the ground to pursue that mission, it could open the way for Israel to declare it achieved the main goal of its ground offensive and to pull troops out of the Gaza Strip.
Kerry, speaking to reporters during a trip to New Delhi, said the parties need to find a way to address Israel's security concerns and to ensure that the people of Gaza can live in safety and dignity.
"All the people involved in this have strong demands and strong visions on what the future should look like. Israel has to be able to live in peace and security, without terror attacks and rockets and tunnels and sirens going off in the day," Kerry said.
"And Palestinians need to be able to live with the opportunity to educate their children and move freely and share in the rest of the world and lead a life that is different from the one they have long suffered," he added.