Israel bombed a UN school sheltering thousands of displaced Palestinians in central Gaza in the early hours of Thursday morning, killing at least 33 people including 12 women and children, according to hospital records and an eyewitness.

The Israeli military said it targeted “20 or 30” Hamas and Islamic Jihad fighters who had taken part in the 7 October attack and were now using the school as an operations centre. The military spokesperson Lt Col Peter Lerner said he was not aware of any civilian casualties.

Missiles hit the second and third floors of the al-Sardi school in Deir al-Balah, where the UN said about 6,000 people were living. Unrwa, the UN agency for Palestinian refugees, called for an investigation into the attack, with scores of people also reported injured.

Ayman Rashed, a shelter resident displaced from Gaza City, said there had been families in the classrooms that were hit, and he helped carry five bodies, including an old man and two children, out from the wreckage.

“It was dark, with no electricity, and we struggled to get out the victims,” he told the Associated Press (AP), adding that the blast had shattered one child’s skull open.

Many of the dead were taken to al-Aqsa hospital in Deir al-Balah, where their bodies were lined up in the courtyard, videos on social media showed.

The hospital initially reported that 14 children and nine women were among the dead. But the hospital morgue later amended those records to show that the dead consisted of three women, nine children and 21 men. It was not immediately clear what caused the discrepancy.

A US-made missile, the GBU 39, was used in the airstrikes on the school, fragments captured in videos and photos from the site show. It is the same weapon used to bomb near Unrwa sites in southern Gaza last week, an attack that caused fires in crowded tent areas that killed at least 45 people.

The Israeli military said that strike, like the one in Deir al-Balah, was a precision hit and the fires may have been caused by secondary explosions, although the prime minister, Benjamin Netanyahu, described it as a “tragic mistake”.

International outrage at the attack increased pressure on Israel over civilian casualties. Days later, the US president, Joe Biden, announced a new ceasefire deal that he described as an Israeli proposal. But as negotiators try to nudge the deal over the line, fighting has intensified in many areas of Gaza.

Also on Thursday night, six victims of another Israeli strike on a house in Deir al Balah were brought to the morgue at the hospital. Even before those deaths, medics at al-Aqsa were struggling to deal with a wave of casualties from a new Israeli offensive in the area, the charity Médicins Sans Frontières (MSF) said.

Eight months into a war launched with a vow to “destroy Hamas”, the militant group has proved resilient across north and central Gaza. Israeli troops redeployed to the area were facing “guerilla warfare”, Lerner said, with small cells using rocket-propelled grenades, small arms and explosive devices to attack.

He said one of those units was using the school as a command and control centre, without providing evidence. He also said Israel had taken steps to protect civilians, including calling off a planned strike on the same site twice in previous days.

“[Hamas] understand that we are cautious and careful around UN facilities, and they are trying effectively to use the UN facilities and building as their iron dome,” he said, referring to Israel’s missile defence system. “They will not have a safe place.”

Hamas officials said its forces were not operating from the school, the AP reported.

Palestinians survey the aftermath of the Israeli strike on a UN-run school. Photograph: Abdel Kareem Hana/AP

The head of Unrwa, Philippe Lazzarini, said: “Claims that armed groups may have been inside the shelter are shocking. We are, however, unable to verify these claims.

“Unrwa shares the coordinates of all its facilities – including this school – with the Israeli army and other parties to the conflict. Targeting UN premises or using them for military purposes cannot become the new norm.”

Schools and refugee shelters are among civilian buildings granted special protection in conflict under international law. Israel says Hamas exploits this protection, illegally using the buildings – and civilians inside as human shields.

The Unrwa communications director, Juliette Touma, said the school was “possibly hit several times” and the number of reported dead was between 35 and 45, with scores more people injured. The UN has not been able to confirm casualty figures.

Since the start of the war more than 170 Unrwa buildings have been hit, the “vast majority” schools turned into shelters. These attacks have killed more than 450 displaced people living there and injured nearly 1,500.

“We call for investigations into all violations against the United Nations including attacks on our buildings,” Touma said.

The strike hit al-Sardi school at about 1.30am local time (2330 BST), when people sheltering there were asleep, the journalist Hind Khoudary said in a video taken at the school that shows pools of blood beside mattresses in a room hit by a missile.

In the courtyard below, children and adults mill around, near balconies hung with bedding and washing. “Children, women are terrified, but unfortunately they don’t have anywhere to go. They are still sheltering in the school,” she said.

MSF said at least 70 bodies and more than 300 wounded people had already been brought to al-Aqsa treatment centre on Wednesday, pushing the battered medical system in the area to the point of collapse.

With the Rafah crossing to Egypt closed, there are no longer medical evacuations for the most severely injured.

Two of the children laid out dead in al-Aqsa hospital after previous strikes had died beside their mother, Abu Mohammed Abu Saif, their father, told Reuters. “This is not war, it is destruction that words are unable to express,” he said.

Israel’s military assault on Gaza has killed more than 36,000 people, mostly civilians, according to health officials in the territory, who say thousands more dead are buried under the rubble.

The war was sparked by an attack by Hamas in southern Israel in October last year, when militants killed about 1,200 people and took 250 hostage.

On Wednesday two food security reports said many Palestinians in Gaza had been killed by months of extreme hunger, and permanent damage had been caused to children through malnutrition, even before famine is officially declared.

The US-based famine early warning system network, Fews Net, said it was “possible, if not likely” that famine began in northern Gaza in April. Two UN organisations said more than 1 million people were “expected to face death and starvation” by mid-July. Israel controls the entry of food aid medical supplies and fuel to Gaza.

Additional reporting by Helen Livingstone, Manisha Ganguly and Elena Morressi