At least four people were killed and dozens injured when a train derailed near the Moroccan capital Rabat on Tuesday, a railway official said.