Some 3,000 Palestinians, including many women and children, were taking refuge in the building in Jebalya refugee camp when it came under fire, according to Khalil al Halabi, director of northern Gaza operations for the UN Relief and Works Agency (UNRWA).
He added: "There were five Israeli tank shells which struck the people and killed many of them as they slept. Those people came to the school because it a designated UN shelter."
An Israeli military spokeswoman said militants had fired mortar bombs from the vicinity of the school and troops fired back in response.
UNRWA said on Tuesday it had found a cache of rockets concealed at another Gaza school - the third such discovery since the conflict began. It condemned unnamed groups for putting civilians at risk.
In addition to the 19 dead, some 125 people were wounded at the Jabalya school, including five in critical condition. An UNRWA source said the agency had recovered fragments from the shells.
Israeli tank fire also struck the main market in Jebalya, killing at least three people and wounding 40 others, while seven members of one family died in an Israeli attack in Deir al Balah in the central Gaza Strip.
The ministry said 1,270 Palestinians, most of them civilians, have been killed since Israel began its offensive on July 8 with the aim of halting cross-border rocket fire.
On the Israeli side, 53 soldiers and three civilians have been killed. Public support remains strong for continuing the operation in the hope of preventing future flare-ups.
Israeli Prime Minister Benjamin Netanyahu reviewed the campaign's progress with his security cabinet and a Palestinian delegation arrived in Cairo for discussions on an elusive truce.
In previous bouts of fighting between Israel and its neighbours, the US has often leaned on the Israelis to stop after incidents that cause high civilian casualties. Washington appears to have less sway with either side this time.
Egypt said it was revising an unconditional ceasefire proposal that Israel had originally accepted but Hamas rejected and that a new offer would be presented to the Palestinian representatives.
UNRWA said it was at "breaking point", with more than 200,000 Palestinians having taken shelter in its schools and buildings following calls by Israel for civilians to evacuate whole neighbourhoods before military operations.
Both US President Barack Obama and the UN Security Council have called for an immediate ceasefire to allow relief to reach Gaza's 1.8 million Palestinians, followed by negotiations on a more durable end to hostilities.
Efforts led by US Secretary of State John Kerry last week failed to achieve a breakthrough and the explosion of violence appeared to dash international hopes of turning a brief lull for the Muslim Eid al Fitr festival into a longer-term ceasefire.
German Foreign Minister Frank-Walter Steinmeier said he was "extremely concerned about the escalating fighting in and around Gaza" .