BERLIN — Twenty-five people were injured, four of them severely, when an explosion destroyed an apartment building in the western German city of Wuppertal, police said Sunday.

Police said the explosion rocked the several-story building shortly before midnight Saturday with a large bang, scaring people in surrounding homes so much they ran out into the street in a panic. The detonation was so severe it destroyed the building’s attic and the top three floors, the German news agency dpa reported.

Fire then broke out in several different parts of the apartment building and firefighters had trouble dousing the flames because parts of the building kept collapsing. They were able to rescue four severely injured from inside the building and sent them to the hospital. Another 21 people were slightly injured and treated by emergency staff at the scene.

Police said they were in the dark about the cause of the explosion, dpa reported.

A car nearby was destroyed, buried under window frames that were blown onto it by the explosions’ impact. Emergency personnel on Sunday picked up bricks and furniture on the street.

Some of the building’s roof beams stood black and eerie in the smoke as police scoured accessible parts of the building for further people trapped inside before giving the all-clear.

Where the building stood is now a huge gap in a row of apartment buildings in the city’s Langerfeld neighborhood.

Later Sunday, authorities brought in heavy equipment to tear down the remains of the ruin. They said it was too dangerous for investigators to search for evidence that might reveal the explosion’s cause because the destroyed building could collapse at any time.