BEIT HANOUN, Gaza Strip — For more than a week, as the war engulfed their homes, families in this northern Gaza town packed up their belongings and children and headed to the one place they presumed would remain safe: the United Nations school.

But in the last few days, the war approached there as well. The Israeli military warned on Monday that the shelter should be evacuated. By Thursday, the United Nations had decided to withdraw its staff and to stop providing food.

Then, as the Palestinians gathered in the courtyard on Thursday, believing they were about to be bused elsewhere, blasts tore through the crowd, killing 16 people and sending scores of wounded, mostly women and children, streaming into local hospitals.

The source of the blasts was unclear, setting off recriminations between Israelis and Palestinians over which side was responsible. People in the school reported three to five blasts and accused Israel of shelling them. Israel suggested that rockets fired by militants might have fallen short of their targets or that the school might have been hit with errant shells from either side in fighting nearby. The United Nations said it could not confirm the source of the blasts.