The shelling set off a fire that raged through the U.N. Relief and Works Agency compound, destroying supplies and forcing Gazans who had taken shelter there to leave.
U.N. Secretary-General Ban Ki-moon told reporters in Jerusalem he had expressed his "outrage" to Israeli Foreign Minister Tzipi Livni and Defense Minister Ehud Barak, The New York Times reported.
Mark Regev, a spokesman for the prime minister, said U.N. officials and agencies must understand "that Israel cannot give immunity to terrorists because they are working from within, or adjacent to, a United Nations compound."
U.N. officials deny Hamas fighters were operating from the UNWRA headquarters.
"They should tell us if there are militants operating in our compound or in our area," said John Ging, who heads U.N. operations in Gaza. "The fact that they don't, we take that as indicative of the fact that there wasn't."