CAIRO -- A locomotive crashed into a barrier at the Egyptian capital's main train station on Wednesday, causing its fuel tank to explode and triggering a huge fire, killing at least 25 people, officials said.

Railway officials said the single railcar was travelling too fast when it collided head-on with the barrier. At least 47 people were also injured, many of them critically, and officials said the death toll could rise.

The explosion and fire blasted through people on the platform in the busy Ramses Station in downtown Cairo. A surveillance video showed the moment of impact when the car barrelled past men and women walking by who are then engulfed in flames and smoke. Charred bodies lay on the platform, and a man in flames ran down a staircase in panic, according to other photos and videos posted on social media.

There was no immediate word on whether the crash was the result of a terrorist act. However, one railway official said it was too early to rule it out. He spoke on condition of anonymity because he was not authorized to brief the media.

Ashraf Momtaz, a general railway inspector, told The Associated Press that there were several scenarios for what happened and one was that someone could have set the rail car on high speed, then jumped.

It was not immediately clear if the locomotive had a driver at the time of the crash, Momtaz said.

"The railcar takes time to (gather) speed so there is a chance that someone set it on full speed before leaving," he said, adding that investigators are considering all scenarios.

"There are records that show which driver is in which railcar," he said.

In general, he said, the accident signals "negligence from the driver and supervisors."

Ambulances rushed to the scene and firefighters struggled to get the flames under control.

Egypt General Prosecutor Nabil Sadek ordered an extensive investigation and sent a team of investigators to the station.

The Ramses district is among the busiest and most crowded areas of the Egyptian capital. The state railway agency briefly halted all train traffic and ordered the evacuation of the station.

Video from surveillance cameras showed flames ravaging the station's interior.

One video that surfaced on social media showed men and women carrying bags and personal belongings and walking on the rail platforms as the train car crashes and explodes.

Another showed men and women running and searching for exits after the explosion. A man is seen running back and forth, his shirt on fire, until another man rushes to pour water on him.

The accident triggered an online debate among many Egyptians, with many blaming the government for not improving railway services in Egypt, even after a series of deadly accidents. Several noted previous statements by Egyptian President Abdel-Fattah el-Sissi expression reservations about spending too much money on improving trains, for lack of funds.

Later in the day, Transportation Minister Hisham Arafat resigned his post, according to a statement released by the Cabinet office.

Mohammed Said, head of the Cairo Railroad hospital, said the death toll could rise.

Many of the wounded were in critical condition, mostly suffering severe burns, said Egyptian Health Minister Hala Zayed.

Prime Minister Mustafa Madbouli said authorities must determine "who caused the accident and hold that person accountable." He promised "harsh punishment" for the culprits.

Egypt's railway system has a history of badly maintained equipment and poor management. Official figures show that 1,793 train accidents took place in 2017 across the country.

In July 2018, a passenger train derailed near the southern city of Aswan, injuring at least six people and prompting authorities to fire the chief of the country's railways.

In March last year, President Abdel-Fattah el-Sissi said the government lacks about 250 billion Egyptian pounds, or $14.1 billion, to overhaul the run-down rail system. El-Sissi spoke a day after a passenger train collided with a cargo train, killing at least 12 people, including a child.

In August 2017, two passenger trains collided just outside the Mediterranean port city of Alexandria, killing 43 people. In 2016, at least 51 people were killed when two commuter trains collided near Cairo.