A train derailed in a densely populated Mexico City suburb on Thursday morning, killing at least five people, local authorities said.

The train, which was transporting grain, crashed in Ecatepec, a large municipality in the State of Mexico that forms part of the urban sprawl extending from the capital.

After the train ran off the tracks shortly before 6 a.m., one of its cars careened into a residential area, killing five people, the Communications and Transportation Ministry said in a statement.

Authorities are in the process of removing debris from the house, and more victims will probably be found, the State of Mexico prosecutor's office said.

The train belonged to Kansas City Southern's Mexican unit, the ministry said. The company did not immediately respond to a request for comment.

The Mexican regulator for railway transport will investigate the accident, the ministry said.

"The government of Ecatepec sends its deepest condolences to the families of the victims and reiterates its support in this difficult moment," Indalecio Rios, mayor of Ecatepec, wrote in a post on Twitter.