The incident took place just before 2.30pm today when the middle section of a row of shops in Brook Hill, Sheffield, came down.
First reports were of a gas explosion, but it was later reported that a retaining wall may have been removed.
A section of the roof gave way and fell into the top floor of the city centre area building above the old Butlers Balti House, on Broad Lane.
Four people were taken to hospital for treatment, though nobody was seriously injured.
Eyewitnesses, one who pulled students from the rubble, said it was as if there had been an explosion in the flats.
“It’s a miracle that nobody was killed. It looks like a bomb went off, or a gas explosion - blowing the front of the building away,” said one man.
About 40 students live in the building but it is not known how many were inside at the time.
South Yorkshire Fire Service said they quickly rescued four people before carrying out a search to check for other casualties in the rubble, but no one else was found.
Incident Commander Stuart Nicholson said: “We had crews on scene very quickly and they were faced with a huge hole in the middle of the three storey terraced building.
“The first and second floors had collapsed onto the ground floor.”
The fire service said there was no fire at the scene and that they did not believe any of the four rescued people had suffered life-threatening injuries.