PESHAWAR, Pakistan — Two trains collided in southern Pakistan on Monday, killing at least 40 passengers and leaving rescuers scrambling to free survivors from the wreckage, authorities said.

The crash occurred before dawn when one express train derailed and was struck by another a little more than a minute later, said a Pakistan Railways spokesman, Tariq Asad. “There was no time for the [second] train to avoid the incident.”

Ashraf Ali, 38, and his brother survived the crash. “It was a shock when the train started derailing; we heard a loud bang,” he said. “I heard cries and screaming.”

Ali and his brother sustained minor injures and managed to escape the wreckage, but many passengers were still believed to be trapped. Local rescue teams rushed to the scene, and the Pakistani military sent troops to help recovery and relief efforts, the armed forces’ media wing said in a statement.

“This is the worst train collision since 2005,” said Asad, the railways spokesman. Deadly train accidents are common in Pakistan, where the country’s extensive rail system has suffered from government neglect for years.

Pakistan’s federal Ministry of Railways ordered an inquiry into the accident, demanding that a report be completed within 24 hours, according to a tweet.

At least 40 people died and more than 100 were injured in Monday’s crash, the deputy commissioner of the district where the crash occurred, Usman Abdullah, told The Washington Post. Abdullah said 12 passengers were seriously injured.

Between 15 and 20 people remained trapped in the wreckage of the derailed train, as authorities sought heavy machinery to aid in the rescue, Ghotki police chief Umar Tufail told the Associated Press.

Images posted to social media after the crash appeared to show one train — the Millat Express — on its side as people tended to injured passengers lying in furrows of dirt.

“It was like a mess. There were shocking howls and cries,” said Riaz Ahmad, 43, a passenger on the train traveling to Karachi who survived the crash with minor injuries.

“It was early morning but still dark and nothing was visible,” he said. “People from the surrounding areas arrived and began helping the victims.”

Officials identified the other train as the Sir Syed Express.

The Millat Express was headed from Karachi to the city of Sargodha when it derailed, fell across the track and was struck by the Sir Syed Express, which was traveling in the opposite direction, a spokesman for Pakistan Railways told the Dawn newspaper.

The incident caused the derailment of more than a dozen train cars and left six to eight “completely destroyed,” Abdullah told Pakistani television station Geo News, according to Dawn.

Munir Ahmed, 29, was one of the local residents who rushed to the scene after he heard the crash. “I was just up for morning prayers but ran to the spot to see what has happened. When I got there, I was shocked.” The scene was “horrible,” he said, describing train cars reduced to twisted metal and dozens of wounded were screaming in pain, many covered in blood.

“Everyone was crying, ‘Help me! Help me!’” he said. “My heart sank.”

Ahmed said passengers were frantically trying to rescue family members from train cars. “I helped a couple of them, “but for a moment I think I lost my senses. I have seen some road accidents before but never saw so many dead and injured.”

In a tweet, Prime Minister Imran Khan said he was “shocked by the horrific train accident” and was ordering a “comprehensive investigation.”

Last year, 22 people died when a passenger train crashed into a bus carrying Sikh pilgrims in eastern Pakistan. In 2019, a massive train fire killed at least 73.

The country’s worst rail disaster occurred in 1990, when a packed passenger train plowed into a standing freight train, killing 210 people.

Hussain reported from Islamabad. Michael Miller contributed to this report.

Read more: