UN Secretary-General Ban Ki-moon says he is appalled by Israeli attacks on a UN compound in Gaza after seeing the destruction for himself.
Mr Ban said that those responsible should be held accountable and demanded a “full investigation” through proper judiciary systems.
He was speaking in front of the smouldering remains of the UN food warehouse destroyed by Israeli shells.
He said he would do all he could to help the population of Gaza.
Mr Ban is the first international leader to visit Gaza for several years, entering through the Israeli-controlled Erez crossing and driving through the bomb-damaged northern suburbs to Gaza City.
He later visited the southern Israeli town of Sderot, which has been one of the main targets of Palestinian rocket attacks in recent years.
He described the rockets as indiscriminate weapons and said the attacks by Hamas are violations of basic humanitarian law.
However, he also called on Israel to end its blockade of Gaza, saying the embargo only strengthens Hamas by fuelling desperation in the impoverished enclave.
Appearing stern and at times angry, Mr Ban called the attacks on Gaza “outrageous” and demanded guarantees that it would never happen again.
“I have protested many times. I am today protesting again in the strongest terms. I have asked (for a) full investigation and (to) make those responsible people accountable,” he said.
“I am just appalled. I am not able to describe how I am feeling. This was an outrageous and totally unacceptable attack against the United Nations.”
CONFLICT IN FIGURES
More than 1,300 Palestinians killed
Thirteen Israelis killed
More than 4,000 buildings destroyed in Gaza, more than 20,000 severely damaged
50,000 Gazans homeless and 400,000 without running water
In depth: Gaza conflict
Q&A: Gaza conflict
Who are Hamas?
Middle East conflict: History in maps
Israeli shells hit the UN headquarters as well as two UN schools during the recent three-week offensive.
The headquarters were badly damaged and nearly 40 people were killed near one of the schools.
Israel said militants used the UN buildings as cover to launch attacks, but the military has launched its own investigation.
As Mr Ban viewed the damage, Hamas held a victory rally near the destroyed parliament building in Gaza City.
The BBC’s Aleem Maqbool, in Gaza City, says the turnout was low, an indication perhaps that Gaza’s population is struggling to see how any side can consider this a victory.
Thousands of Gazans have been left homeless by the Israeli offensive and Palestinian officials warned it could cost $1.9bn to rebuild the territory.
Israeli troops are expected to complete their pull-out later, if the current ceasefire holds.
Israeli political sources say the military aims to have withdrawn before Barack Obama’s inauguration as US president at 1700 GMT.
But there have been several violent incidents during the day.
The Israeli navy fired shells into Gaza in what it called a deterrent measure, and reports claimed that a mortar shell was later fired into Israel from Gaza.
Two children were killed near Gaza City in an explosion of ordnance left behind by the Israeli army, according to Palestinian medical officials.
And in the West Bank, an Israeli man was shot and seriously wounded while driving near the Kochav Hashachar settlement.
A previously unknown group calling itself the al-Bashair Army told the Palestinian news agency, Maan, it had carried out the attack.
Earlier, the UN’s top humanitarian official, John Holmes, said hundreds of millions of dollars of aid would be needed immediately to help Gaza’s 1.4 million people.
In pictures: Devastation in Gaza
New Israel phosphorus accusation
Gaza doctor’s loss grips Israelis
Agencies rush aid to Gaza Strip
While 100,000 people had their water supply restored on Sunday, 400,000 still had no water, he said.
Separately, the Palestinian Central Bureau of Statistics estimated that the overall physical damage so far amounted to about $1.9bn (£1.4bn).
The UN has asked Israel to open Gaza’s borders to allow in construction materials, but so far only basic humanitarian supplies have been let in.
Meanwhile, Arab foreign ministers meeting in Kuwait have failed to issue a statement on the Gaza situation because they disagreed over who was to blame for the conflict.
Egypt said Hamas had invited the attacks, while Syria said Israel should be declared a terrorist entity.
Palestinian medical sources say at least 1,300 Palestinians were killed, nearly a third of them children, and 5,500 injured during the conflict. Thirteen Israelis, including three civilians, were killed.