A third deadly attack on a United Nations school sheltering people fleeing bombardment in Gaza was strongly condemned by both the UN and the US on Sunday, with UN chief, Ban Ki-moon, calling it a "moral outrage and a criminal act" and pleading for an end to "this madness".

The Israeli defence ministry said on Sunday night that Israel would hold a truce in most of Gaza for seven hours on Monday for humanitarian aid and to allow displaced Palestinians to return to their homes, but would fight back if attacked.

The humanitarian truce, beginning at 10am (0700 GMT), would not apply in areas of Rafah, the ministry said, because Israeli forces are remaining on the ground in and around the southern Gaza town to destroy a cross-border tunnel.

The US said it was appalled by the "disgraceful" school attack, which killed at least 10 people and injured dozens just days after the shelling of two other UN schools in Gaza caused international shock and anger.

A hospital near the site of the attack, in the southern town of Rafah, was overwhelmed with the dead and injured. Children's bodies were stored in an ice-cream freezer as the morgue ran out of room.

It was, said Ban, "yet another gross violation of international humanitarian law, which clearly requires protection by both parties of Palestinian civilians, UN staff and UN premises, among other civilian facilities". He called for a swift investigation, saying "those responsible [must be] held accountable. It is a moral outrage and a criminal act."

The Israel Defence Forces (IDF) had been "repeatedly informed of the location of these sites", Ban added.

In an unusually severe statement, the US state department called on Israel to do "more to meet its own standards and avoid civilian casualties".

The Israeli military was investigating the incident, said a spokesman, but preliminary inquiries had shown that its forces were "targeting a number of terrorists on a motorbike near the school, and we did identify a successful hit on a motorbike. We do not target schools. We certainly do not target civilians. We are still reviewing the incident."

The attack came as Israeli forces began withdrawing most troops from Gaza in what the military described as a "new phase" in the 28-day conflict. Air strikes and shelling continued alongside the troop redeployment and Hamas continued to launch rockets at Israel.

"The troops are in the midst of a redeployment to other parts of the border," said IDF spokesman Lt-Col Peter Lerner. "We are releasing troops from the frontline but the mission is ongoing. Ground forces are operating. Air forces are operating."

Troops were "extremely close" to completing a mission to destroy Hamas's network of attack tunnels, he said. The IDF had "a rapid reaction force on the ground that can engage Hamas if required".

Residents of some areas of Gaza, who had been warned to evacuate, were told they could return to their homes. The IDF has dropped leaflets in parts of Gaza telling residents to "tell your hidden leaders the battle is over" and that "all members and leaders of Hamas and other terrorist movements are unsafe".

Residents, who reported limited shelling overnight in the northern areas, were reluctant to return to their homes following the breakdown of previous ceasefires.

Israeli analysts said that Israel was effecting a unilateral winding down of the military operation rather than engage in truce negotiations with Hamas. Yossi Melman, a respected commentator, wrote in Ma'ariv: "After 27 days of fighting and 63 IDF soldiers killed—the war is over … It is a unilateral political decision that is based on a military assessment. The IDF will deploy along defensive lines in a security zone inside the Gaza Strip and, at the same time, will reduce the number of troops and redeploy many of them in staging grounds inside Israel.".

Despite the truce, the international community is likely to be alarmed at Israel bypassing negotiations. Political leaders and senior diplomats have repeatedly stressed that the two sides must address and resolve underlying issues that led to the current conflict to break the cycle of violence.

Efforts to forge a truce resumed in Cairo on Sunday, with Middle East envoy Tony Blair and US special envoy Frank Lowenstein flying in, along with a Palestinian delegation which included representatives of Hamas and Islamic Jihad, the main militant groups in Gaza.

Israel declined to send a team to join the talks, , an indication that it wants to proceed on its own terms, diminishing prospects for an early breakthrough.

Among demands tabled by the Palestinians were an end to the blockade of Gaza, extending the permitted fishing zone at sea and the removal of the no-go buffer zone inside the border, as well as the rehabilitation of Gaza, emergency aid and a release of prisoners.

As diplomats prepared for talks in Cairo, the funeral took place of Hadar Goldin, a 23-year-old soldier whom Israel originally said had been captured by Hamas during an attack near Rafah on Friday. Hamas denied it was holding the soldier. Israel retaliated for the attack – in which two other soldiers were killed – with massive bombardment of the area.

In a statement issued on Saturday night, the IDF said Goldin had been killed in battle, bringing the number of soldiers killed to 64. It also confirmed he was related to the defence minister, Moshe Ya'alon.

Sami Abu Zuhri, Hamas's spokesman in Gaza, told reporters: "Israel tricked and deceived the world when it claimed a soldier had been abducted and then admitted that he had actually been killed in battle in Rafah. It did this only in order to breach the 72-hour ceasefire agreed upon with the UN and the US, in order to commit massacre in Rafah."

Praising the soldier as a "great hero", the Israeli prime minister, Binyamin Netanyahu, told Goldin's parents: "I hope that you will find consolation in the fact that he fell to uphold the people of Israel in the struggle for our independence."

The UN warned of a rapidly unfolding health disaster in Gaza, with overwhelmed medical services on the verge of collapse. It said a third of hospitals, 14 primary healthcare clinics and 29 ambulances had been damaged in the fighting, at least five medical staff had been killed on duty and more than 40% of medical staff were unable to get to places of work.

Critical supplies of medicines and other supplies were almost depleted and damage and destruction of power supplies had left hospitals dependent on unreliable generators.

The Palestinian death toll passed 1,750, 80% of whom are civilians, according to UN estimates. About 460,000 people have been displaced since the start of the conflict.

The UN said many were "now living in overcrowded conditions in schools, with relatives or in makeshift shelters. This, coupled with lack of inadequate water and sanitation, poses serious risks of outbreak of waterborne and communicable diseases."

Meanwhile, a statement signed by the EU and European commission presidents on behalf of 28 member states has called on Israel and Hamas to "immediately stop" hostilities and condemned the loss of life.

"The bloodshed needs to stop. We deplore the terrible loss of lives, including innocent women and children," it said, saying Gaza residents were suffering "intolerable violence". It also called the continued rocket fire by Hamas "an unacceptable threat" to Israeli citizens.