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 local media.

Footage on local media show 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, authorities said, while anxious relatives have camped out at the school overnight awaiting news of their loved ones.

Authorities are concerned about the building's structural integrity, which has taken on a pancake-like structure with layers of concrete slabs leaving only narrow voids, complicating the rescue operation. Rescuers are using specialized tools as the site poses serious risks with the potential for further collapses.

Survivors recount the horrifying moment the building fell, with students expressing their shock as they fled the collapsing structure, highlighting issues around the safety regulations of such educational buildings in Indonesia.

This tragedy underscores the ongoing concerns about safety standards in Indonesia's construction sector, particularly affecting educational institutions, a situation that requires urgent attention from the authorities.