A freight train derailed in the middle of the night in northern Italy, setting off an explosion and a fire that killed at least 13 people and sent 50 others to the hospital, many with severe burns, officials said Tuesday.

The 14-car train was traveling from the northern city of La Spezia to Pisa when a rear car plowed into a residential neighborhood beside the train station in the Tuscan seaside town of Viareggio just before midnight Monday.

A train car filled with liquefied petroleum gas exploded, collapsing at least two buildings and setting fire to a vast area. Homes collapsed or burned, killing residents as they slept.

"We saw a ball of fire rising up to the sky," said witness Gianfranco Bini, who lives in a building overlooking the station. "We heard three big rumbles, like bombs. It looked like war had broken out."

Videos uploaded on YouTube showed a huge plume of fire and smoke towering above Viareggio's low houses. An inferno raged through the night, consuming buildings and cars, while the sound of sirens and explosions pierced the air.

The death toll stood at 13 by Tuesday morning, said Gennaro Tornatore, a spokesman for the firefighters. But he said the number of victims might rise as 300 firefighters and other rescue teams searched through the rubble.

The city of Lucca's top government official, Prefect Carmelo Aronica, told Italy's RAI state TV that at least 50 people were injured, with 35 hospitalized with severe burns. The ANSA news agency reported that three children were pulled alive from the rubble of their collapsed home shortly before daybreak Tuesday.

About 1,000 people were evacuated from their homes as a precaution, and tents were set up around the town hall.

As the firefighters worked to contain the blaze, teams specialized in dealing with nuclear, biological and chemical threats were being brought in to prevent the other gas tanks from exploding. Officials said the fire was contained after several hours, but a smell of burning hung in the air.

"There are dozens and dozens of cars hit by the shock wave and collapsed houses," said firefighters' spokesman Luca Cari.

Some of the victims, including a child, were killed in their homes, said Raffaele Gargiulo, a police spokesman for the nearby city of Lucca, which is in charge of the smaller town of Viareggio. Two drivers on the road alongside the tracks when the train derailed were also killed.

Others suffered severe burns and died at the hospital.

"The condition of the bodies is such that it will be very difficult to identify them," Gargiulo said.

The train's two engineers were only lightly injured. While being questioned in the hospital, they said they felt an impact some 650 feet outside the station, shortly before the rear of the train flew off the tracks, Gargiulo said.

He told The Associated Press by telephone that the derailing may have been caused by damage to the tracks or by a problem with the train's braking system.