A man was hit by a train on Monday morning as it passed through the Boavista area of Portimão.
The head of the Portimão Bombeiros said the driver had phoned through to report that the train had hit someone.
Rail services were suspended between Portimão and Lagos while the firefighting team, police and medics attended the scene.
According to the police, the 21-year-old, later named as Ricardo Rijo da Costa, was on the line in an unprotected area often used by locals to cross the line, when he was hit by the train which killed him outright.
The driver said the man was using his mobile phone and that a collision could not have been avoided.