Hundreds of Palestinians were in the school in Beit Hanoun, fleeing heavy fighting in the area.
It is the fourth time that a UN facility has been hit in Israel’s offensive against Hamas militants.
In the past 16 days of fighting, more than 750 Palestinians and 32 Israelis have been killed, officials say.
Israel launched its military offensive on 8 July with the declared objective of stopping Hamas firing rockets from Gaza.
Pools of blood
Earlier on Thursday, UN humanitarian chief Valerie Amos said that it was “vital” to have a ceasefire.
“We have over 118,000 people now who are sheltering in UN schools… people are running out of food. Water is also a serious concern,” she said.
She said the conflict meant 44% of Gaza was a no-go area for Palestinians, and residents were running out of food.
Israeli PM Benjamin Netanyahu said on Thursday he regretted each Palestinian civilian death, but said they were “the responsibility of Hamas”.
Correspondents say pools of blood lay on the ground in the courtyard of the school in Beit Hanoun in northern Gaza.
There was a large scorch mark where it appeared a shell had hit, the Associated Press news agency reports.
UN officials said that during the course of the day they had been trying to negotiate a window of time with the Israeli army for civilians to leave the area because of the heaving fighting.
But Chris Gunness, a spokesman for the UN Relief and Works Agency for Palestine refugees (Unrwa), said it was never granted.
He said the Israeli army had been formally given the co-ordinates of the shelter in Beit Hanoun.
There has been no comment so far from the Israeli military.
The BBC’s Chris Morris in Gaza says casualties from the attack have been taken to several local hospitals.
But at the school itself journalists trying to reach the scene have had to pull back, after small arms fire broke out nearby, he says.
The UN’s Office for the Coordination of Humanitarian Affairs (Ocha) says a 1.9 mile (3km) wide strip, encompassing 44% of Gaza, has been designated as a no-go zone by the Israeli military.
Meanwhile Khaled Meshaal, leader of Islamist militant group Hamas, said there could be no ceasefire to ease the conflict in Gaza without an end to Israel’s blockade.
Israel imposed restrictions on the Gaza Strip in 2006, after Hamas abducted Israeli soldier Gilad Shalit.
The measures were tightened by Israel and Egypt in 2007, after Hamas ousted rival Fatah and forcibly took control in Gaza after winning elections the year before.
Hamas and Fatah announced a reconciliation deal in April, but the move was condemned by Israel which regards Hamas as a terrorist group.
Israel’s Science Minister Yaakov Peri told Israeli web portal Walla that he did not see a ceasefire being agreed in the coming days, as the Israel Defence Forces (IDF) needed more time to dismantle Hamas’ underground tunnel network.
There have been hundreds of rocket attacks on Israel, and Israeli air strikes on Gaza, since the Israeli offensive began.