
A freight train carrying diesel has derailed and burst into flames.
People living within 800m of the blaze in Llangennech, near Llanelli in Carmarthenshire, were evacuated from their homes on Wednesday night, but have since been allowed to return.
Police declared a major incident, put a cordon in place and closed roads.
The two workers who were on board the train have been accounted for and no injuries have been reported, British Transport Police (BTP) 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 police said it had been declared a "major incident" due to the "initial risk of harm" to people nearby.
Louise Perkins, who lives close to the railway line, said she grabbed some stuff and rushed from her home with her children, aged seven, 12 and 19, in the middle of the night.
The 38-year-old was up late watching TV when she heard an enormous bang: "There was this massive fire and black smoke.
"As we left it was just fire - you could see like balls of it puffing up, and the smell... the smell of diesel.
"It was just everywhere, and there were just black, black clouds of smoke in the air."
Ms Perkins said she was "quite worried" when police explained "it could explode".
"At that point my children were up and and they got really distressed," she said.
Her 19-year-old son went to his friend's house while her two younger children went to their grandmother's.
"They were worried - 'oh, what if our house catches fire, what about all the stuff?'" she explained.
"I told them not to panic But my youngest was really upset, she's seven, she was just heartbroken, she was crying."
BTP said it was conducting initial inquiries, including "securing key witness statements and CCTV".
Assistant Chief Constable Sean O'Callaghan said: "The fire continues and there is still a substantial risk within its immediate vicinity, so our advice remains for people to avoid the area.
"Once the fire has been extinguished, and the scene is safe to assess and investigate, we'll be working with the Office of Rail and Road and the Rail Accident Investigation Branch to establish the exact circumstances behind the incident."
Police said it had been a "fast-moving situation".
Sup Ross Evans, of Dyfed Powys Police, 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."
Those evacuated had been asked to meet at Bryn School and Llangennech Community Centre, police added.
Gary Jones, a councillor for Llangennech, said the fire "seemed to die down and then there seemed to be fresh explosions".
"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."