At least 55 others were wounded in the accident, which occurred in Girzah district of 6th of October province, said the official, speaking on condition of anonymity because he was not authorized to talk to the media.
Emergency personnel worked to extract the dead and wounded from the trains, said the official.
The train that caused the collision was headed from Cairo to the southern city of Assuit, while the one ahead of it was traveling from Giza province to the oasis town of Fayoum, said Egypt's official Middle East News Agency.
Egypt has a poor safety record on its railways, and there are several fatal accidents each year, usually blamed on poorly maintained equipment.
The country's worst railway disaster took place in February 2002 when a train heading to southern Egypt caught fire, killing 363 people.
More recently, a passenger train barreling toward a station collided with a second train in August 2006, killing 58 people. The train belonged to the country's oldest and most dilapidated third-class train service.
The crash stirred a wave of outrage among Egyptians over the poor state of transportation infrastructure. The transportation minister, Mohammed Mansour, acknowledged after the accident that the rail system was in need of a major overhaul and was severely underfunded.
The incident prompted the government to approve an immediate allocation of $860 million to develop the rail infrastructure, plus another $600 million in loans to the sector later in that year.