The roof of a private school in Peshawar, in northwestern Pakistan, gave way during classes on Thursday, killing at least 32 students and a teacher, most of them children younger than 13, officials said.

The collapse at the Al-Khair Education Centre in the capital of Khyber Pakhtunkhwa province injured more than 45 people, Al Jazeera reported, citing the authorities and rescue officials. Mohammad Asim, a spokesman for Lady Reading Hospital, said most of the dead were 6 to 12 years old. The oldest was 14. Twelve were girls, and the teacher was a woman.

The count rose all day. Early tallies put the number of students killed at 21, then 27, then 28. Later on Thursday, The Express Tribune reported that 34 children and a female teacher had died, counting 33 bodies brought to Lady Reading Hospital and two to Naseerullah Babar Memorial Hospital. It put the number of injured at more than 50.

A worn school desk and chair with a backpack stand amid rubble in a ruined classroom, lit by sunlight through broken windows.

A rescue official said the roof of a higher floor came down first and brought the ceiling down onto the students, crumpling two storeys of the three-story building.

Peshawar’s police chief, named as Mian Saeed by The Guardian and as Saeed Ahmed by Al Jazeera, put the blame on the building itself. “It was a weak building structure,” he said. “Its roof was overweight with construction on a weak structure that caused the collapse.”

The police arrested the school’s owner, Mohammad Khan. He reportedly blamed rain earlier in the week for weakening one of the roofs. School officials had no immediate comment.

Rescuers dug through the rubble by hand and carried injured children to ambulances while residents crowded the narrow alley outside, according to television footage described by Al Jazeera. “We have taken out at least 45 children,” Iftikhar Khan, the district emergency officer, said at the time, and more children were reported to be buried.

Dust-covered hands lift a large broken masonry block amid rubble in a narrow, damaged street.

How many students were inside isn’t settled. The police chief said that only 47 of the 110 students in the three affected classrooms had been rescued by midday. The Express Tribune reported that 110 children were enrolled and 75 were in class. An injured teacher told The Associated Press that the school had about 1,200 students.

Bilal Faizi, a spokesman for the emergency services, said almost 100 rescuers took part, parents among them, and that getting children out quickly saved at least 40 lives. Rescue officials said everyone trapped had been pulled out within hours. Lady Reading Hospital declared an emergency and took in 20 of the injured, Mr. Asim said, some of them in critical condition.

President Asif Ali Zardari and Prime Minister Shehbaz Sharif issued statements of condolence. “The entire nation shares the grief of the affected families in this hour of sorrow,” Mr. Zardari said.

The provincial government has formed a committee to find out why the roof fell. The police said their own investigation was continuing.