At least 49 people have been killed and dozens more injured in a train collision in Egypt's coastal city of Alexandria, the country's health ministry said.

State news agency MENA reported that two trains were involved in Friday's accident.

Footage broadcast on state television showed one train had partly keeled over in the crash, and medics were seen moving the dead and injured to ambulances.

A witness said the trains rose into the air "forming a pyramid" as they slammed into each other just outside a suburban station in the Mediterranean port city.

The collision at 2:15 pm (12:15 GMT), near Khorshid station at the edge of Alexandria, derailed the engine of one train and two cars of the other, the Egyptian Railway Authority said.

Transport Minister Hisham Arafat said "human error" led to the collision but did not elaborate.

"In order to avoid it, we have to develop the infrastructure," he told state television.

One resident, Hoda, was standing on her rooftop when she saw the trains plough into each other.

"They rose in the air forming a pyramid when they collided," she said. "I started to scream from the rooftops for people to grab some sheets and run."

Roads and railways in Egypt have a poor safety record, and people have long complained that the governments have failed to enforce basic safeguards.

In February 2016, dozens were injured when a train derailed after crashing into a concrete barrier south of capital Cairo.

In early 2015, a crash between a train and a bus carrying schoolchildren northeast of Cairo killed at least seven people.

In 2013, 19 people were killed and 103 other injured, when a military train carrying young recruits to an army camp derailed in Giza.

Fifty people, mostly children, were killed when a train crashed into a school bus as it crossed the tracks at a rail crossing south of Cairo in 2012.

Egypt's deadliest railway tragedy happened in 2002 when more than 360 people were killed by a train fire.