One person died in a train crash near Barcelona.

The driver of a passenger train died on Monday evening when a derailed freight train collided with his train at the entrance to a station, according to the Catalonia region's civil protection agency.

86 people were injured in the accident in Sant Boi de Llobregat, most of them slightly.

It was initially unclear why the freight train loaded with potash derailed and crashed into the driver's cab of the other train around 6 p.m.

Spanish Prime Minister Pedro Sánchez expressed his condolences to the family of the deceased train driver.

An examining magistrate has been commissioned to deal with the case, the higher regional court of the Catalonia region said on Tuesday.

On Tuesday, the affected railway line west of Barcelona remained closed due to the recovery of the locomotives and wagons.

According to official information, the collision happened when some of the wagons of the freight train derailed and collided with the oncoming passenger train on a parallel track as it exited the station.

Video footage showed an overturned brown freight car digging into the front of the suburban train.