One person has died and six others have been slightly injured after a landslide derailed a commuter train travelling to Barcelona.

The regional civil protection agency said two train cars from a convoy of six went off the tracks at 6.15am near Vacarisses, around 45 kilometres northwest of Barcelona.

Spanish railway operator spokesman Antonio Carmona has told local media heavy rain in the area over the past few days could have caused the landslide.

Around 150 people were travelling on the train, according to the civil protection agency.
Firefighters and emergency workers are working to evacuate the trapped commuters.