Rescuers are racing to pull dozens of students and workers from under the rubble of a school building that collapsed in East Java, Indonesia. Three people have been killed and 99 others hospitalised, some of them with critical injuries, officials said Tuesday, adding that the death toll may rise.

At least 38 others, many of them teenage boys, remain trapped under the Al Khoziny Islamic Boarding School in the East Java town of Sidoarjo. They had gathered for prayers when the building gave way on Monday.

The two-storey building had an unstable foundation and could not support the weight of the construction of two more floors, the disaster mitigation agency said.

The girls were praying in another part of the building and managed to escape, according to the Associated Press.

Students in the school, which serves ages 12 to 17, reported a chaotic scene. Footage shows the collapsed part of the building completely sunken in, with large slabs of concrete sticking out.

Crying and shouting can be heard from the rubble, while anxious relatives camped out at the school overnight waiting for news.

Dozens of rescuers have been working through the night but the operation was temporarily suspended on Tuesday due to the risk of further collapses. Mohammad Syafeii, head of the search and rescue agency Basarnas, described the building's condition as a 'pancake type structure', complicating rescue efforts.

Survivors recounted their experiences, with one seventh grader recalling hearing falling rocks just before the collapse and managing to escape with injuries. The school's caretaker has extended apologies to families as investigations reveal that the facility had not obtained proper permits for construction.

The tragedy highlights the urgent need for improved safety measures in Indonesia's construction sector, which has a poor safety record. The community and authorities continue to grapple with the aftermath of this devastating incident.