Media playback is unsupported on your device
A freight train carrying diesel has derailed and burst into flames, sparking a huge fire.
People living within 800m of the blaze on tracks at Llangennech, near Llanelli in Carmarthenshire, were evacuated on Wednesday night, but have since been allowed home.
Police declared a major incident and put a cordon in place and closed roads.
Two workers on the train are accounted for and no injuries have been reported, British Transport Police said.
One Twitter user said they could smell burning fuel from "well over a mile away".
The fire was reported at about 23:20 BST on Wednesday and Supt Ross Evans said it had been declared a "major incident" due to the "initial risk of harm" to people nearby.
Image copyright Pembrokeshire Herald Image caption Emergency services had dealt with a "fast-moving" and "large scale" situation, police sayPolice said it had been a "fast-moving situation" and people within 800m of the train were asked to leave their homes.
Sup Evans added: "The policing response was large scale, with officers across the force retained on duty to ensure we had sufficient resources to carry out the evacuation swiftly, as well as the deployment of a logistics specialist to assist and advise our officers on safely moving people from their homes to the reception points.
"The evacuation no doubt caused a significant amount of disruption for those evacuated in the middle of the night and I would like to personally thank residents for their response, as well as our frontline officers who swiftly moved hundreds of residents out of their homes."
Image caption Llangennech is near the Carmarthenshire-Swansea county border, in south-west WalesThose evacuated had been asked to meet at Bryn School and Llangennech Community Centre, police added.
British Transport Police has asked people to avoid the area.
Gary Jones, a councillor for Llangennech, said the fire "seemed to die down and then there seemed to be fresh explosions".
Image copyright @missjones1994 Image caption People have been advised to avoid the area"The height of it was incredible," he told BBC Radio Wales.
Mr Jones said about 100 people were evacuated and up to 40 went to the community hall, which has not reopened since the coronavirus lockdown.
He added: "Everyone has gone home now. The village is blocked, you can't leave the village at the moment."
Image copyright Pembrokeshire Herald Image caption Multiple emergency services and agencies attended Image copyright Pembrokeshire Herald Image caption Residents needed evacuating as the fire service worked to bring the blaze under control