MEXICO CITY (AP) _ An explosion caused by confiscated fireworks shattered a downtown fire station Friday and injured at least 39 people, officials said.

''It was so sudden. I thought that a bomb had exploded,'' said one fireman who did not give his name. He was about 30 feet away at the time.

The fire station is only four blocks from Mexico's Legislative Palace, which was severely damaged by a fire earlier in the day.

The Red Cross said eight injured firemen and one civilian were taken to hospitals by Red Cross ambulances after the early evening blast.

Saul Escobedo Ramirez, chief of ambulances at the police rescue service, said their ambulances picked up 30 injured - 23 firefighters and seven civilians.

Carlos Esperanza Garcia, chief doctor at the nearby Hospital Ruben Lenero, said five people were taken there with burns.

Fire official Roberto Jaime Rangel said 15 tons of fireworks had been stored outdoors at the fire station. He blamed the explosion on ''overheating.''

Fire Chief I. Ponce de Leon said the fireworks had been seized in nearby markets and stored at the station for about six weeks. He said the army routinely picks up seized fireworks and disposes of them, but for some reason hadn't done so before the blast.

Anne LaBrousse, a witness who arrived at the scene shortly after the explosion, said windows were shattered in buildings near the one-story fire station and that some interior walls had been blown down. She said a huge cloud of white smoke rose over the scene.

The blast was heard 10 blocks away in the Zocalo, Mexico City's central square, where supporters of leftist politician Cuauhtemoc Cardenas had gathered for a rally.