Gaza's Civil Defence spokesperson Mahmud Bassal said 18 people were killed in the strike on al-Jaouni school in Nuseirat refugee camp, which is being used as a shelter by thousands of displaced Palestinians.
Israel's military says it carried out a “precise strike on terrorists” planning attacks from the school, and that it had taken measures to avoid harm to civilians.
UN Secretary General Antonio Guterres said the attack amounted to "dramatic violations of international humanitarian law" in a post on X.
Unrwa said the attack marked "the highest death toll among our staff in a single incident" since the start of the war between Israel and Hamas in October. The body said it was the fifth time the school had been hit over the past 11 months.
In July, 16 people were reportedly killed in a strike which the Israeli military said had targeted several structures at the school used by Hamas fighters.
Hamas - which is proscribed as a terrorist group by Israel, the UK and other countries - has denied using schools and other civilian sites for military purposes.
Israel's ambassador to the UN, Danny Danon. hit out at Guterres' criticism of the strike and said it was "unconscionable that the UN continues to condemn Israel in its just war against terrorists".
Israeli forces launched a campaign to destroy Hamas in response to the group's unprecedented attack on southern Israel on 7 October, in which about 1,200 people were killed and 251 others were taken back to Gaza as hostages.
More than 41,080 people have been killed in Gaza since then, according to the territory's Hamas-run health ministry.
UN spokesman Stéphane Dujarric told reporters the UN condemned “all air strikes that target civilians and those that also target UN facilities”.
Video of the aftermath of Wednesday’s air strike showed hundreds of people inspecting the heavily damaged ground floor of one wing of al-Jaouni school, as well as the remains of an adjoining structure that appeared to have been destroyed.
Other footage showed ambulances bringing wounded men, women and children said to have been wounded in the strike to al-Aqsa hospital in the town of Deir al-Balah.
In a post on Telegram, the Hamas-run Civil Defence agency identified one of those killed as the daughter of one of its rescue workers, Momin Salmi. It said he had not seen Shadia for 10 months because he had stayed in northern Gaza while his wife and their eight children had fled southwards.
The Israel Defense Forces (IDF) said aircraft had “conducted a precise strike on terrorists who were operating inside a Hamas command and control centre” embedded inside al-Jaouni school.
“Numerous steps were taken to mitigate the risk of harming civilians, including the use of precise munitions, aerial surveillance and additional intelligence,” it added.
“This is a further example of the Hamas terrorist organisation’s systematic abuse of civilian infrastructure in violation of international law.”
Gaza’s Hamas-run government media office accused Israel of a “brutal massacre”.
Later, Unrwa said in a statement that two air strikes had hit the school and its surroundings, which were home to around 12,000 displaced people, mainly women and children.
"Among those killed was the manager of the Unrwa shelter and other team members providing assistance to displaced people," it said.
The agency insisted that "schools and other civilian infrastructure must be protected at all times", adding: "They are not a target."
"We call on all parties to the conflict to never use schools or the areas around them for military or fighting purposes."
Hours before the incident, Unrwa said in a situation report that almost 70% of its schools in Gaza had been hit during the war.
It also reported that 214 of its staff members had been killed, along with at least 563 displaced people who had been sheltering inside its schools and other installations.
Israel has previously accused Unrwa of supporting Hamas.
The agency has denied this, but the UN said in August that it had fired nine of Unrwa's 13,000 staff in Gaza after investigators found evidence that they might have been involved in the 7 October attack. Another 10 staff were cleared because of insufficient evidence.
Israel also alleged that hundreds of Unrwa staff were members of terrorist groups, but a UN review published in April found Israel had not provided evidence for its claims.
In a separate development on Wednesday, the IDF announced that two Israeli soldiers had been killed and eight others injured in a helicopter crash overnight in southern Gaza.
The helicopter was on a mission to evacuate a critically injured soldier to a hospital for medical treatment and crashed while landing in the Rafah area, a statement said.
“An initial inquiry conducted indicates that the crash was not caused by enemy fire. The cause of the crash is still under investigation,” it added.
David Gritten