The secretary general of the United Nations has called for a full investigation into Israel's shelling of three of its buildings in the Gaza Strip during its three-week long assault against Hamas.

A visibly furious Ban Ki-moon condemned as "outrageous, shocking and alarming" the destruction he had seen while touring Gaza, and described as "excessive use" of force the violence wrought by both Israel and Hamas rockets.

"These are heartbreaking scenes I have seen and I am deeply grieved by what I have seen today," he said, standing against a backdrop of still-smoking food aid in a UN warehouse destroyed by Israeli gunfire last Thursday.

Demanding a proper judicial inquiry and guarantees that UN buildings would not be attacked again, Ban said: "I am just appalled. I am not able to describe how I am feeling, having seen this site of the bombing of the United Nations compound. This was an outrageous and totally unacceptable attack against the United Nations."

An aide to Ban said he had come to Gaza to express solidarity with the Palestinians who had suffered during the 22-day Israeli assault.

Ban's comments follow furious remarks delivered by senior officials of the UN Relief and Works Agency (UNRWA) at the weekend when two children were killed by Israeli shellfire at a school where hundreds of people were taking refuge. Officials then called for an inquiry into "possible war crimes".

During the conflict Israeli shells hit the UN headquarters in Gaza as well as two UN schools, killing nearly 40 people near one of the schools in the worst incident.

Although the Israeli military announced on Saturday that it would launch an inquiry at the "highest level" into the five most controversial incidents where civilians were killed – including the targeting of UN buildings – it appeared to have pre-judged that inquiry by adding that initial Israeli Defence Force (IDF) investigations had shown hostile fire was coming from or near all five locations before they were hit.

Ban's comments came as Israel's foreign minister and leader of the Kadima party, Tzipi Livni, made clear that Israel would only consider acceding to a UN security council resolution demanding a full lifting of the economic blockade on Gaza – in force for a year and a half – when Hamas released Corporal Gilad Schalit, who has been in captivity since 2006.

"He is an IDF soldier," the foreign minister said during a speech in Rishon Lezion. "We sent him to defend the country and we have an obligation to bring him back.

"If Hamas thinks it wants to get something beyond humanitarian assistance, which we will give regardless, we have someone who is very important to us, and, for me; one thing is contingent upon the other."

Earlier today thousands of Hamas supporters gathered for what the Islamist group's leaders described as a victory rally in a square outside the remains of the parliament building in Gaza City, which was heavily damaged in an Israeli air strike. Two men hoisted a sign in Hebrew reading: "The resistance will be victorious, Israel has been defeated".

Financial estimates of the full cost of the Israeli bombardment of Gaza reflect the scale of the destruction: the Palestinian Central Bureau of Statistics put total property damage at $1.9bn (£1.3bn).

The UN's humanitarian chief, John Holmes, speaking in New York, said the organisation's staff in Gaza were trying "to find out as much as they can about how great the damage is and how great the needs are".

He said: "On the purely humanitarian and early recovery side … it will be hundreds of million of dollars and no doubt the overall reconstruction costs will be numbered in billions of dollars, but I wouldn't want to put a figure on it beyond that."

Saudi Arabia has already pledged $1bn towards repairing the damage. European Union foreign ministers are due to meet in Brussels shortly to discuss humanitarian aid and Israeli demands for the prevention of weapons smuggling into Gaza.

More than 1,300 Palestinians were killed in Israel's attacks, which Israel said were intended to halt cross-border rocket attacks and destroy Hamas's military infrastructure.

Hamas has said 5,000 homes, 16 government buildings and 20 mosques were destroyed and 20,000 houses were damaged in the assault; Israel claimed militants hid weapons inside the mosques. Palestinian militant groups said 112 of their fighters and 180 Hamas policemen were killed. Israel put its dead at 10 soldiers and said three civilians were killed in rocket attacks.

Medical officials have confirmed that 700 Palestinian civilians were killed, and that figure is likely to rise as survivors return to search through the rubble of their shattered homes. As many as 400,000 Gazans have been left without running water.

Israel, which accused Hamas of endangering non-combatants by operating in densely populated areas, alleged that hundreds of militant Hamas fighters were among the dead.

In Geneva the director general of the World Health Organisation, Margaret Chan, warned of a looming health crisis among the 1.5 million Gazans. She said she was "deeply concerned" about the interruption of immunisations and other life-saving care, and the limited availability of hospital beds in Gaza.

Last night an Israeli man was shot and seriously injured while driving near the Kochav Hashachar settlement in the West Bank. The previously unheard of al-Bashair army claimed responsibility for the attack.