Two people escaped unhurt after a “significant” fire on a freight train carrying diesel.

Emergency crews were called to Llangennech, near Llanelli, in South Wales, and nearby homes were evacuated after the blaze was reported at around 11.20pm on Wednesday.

British Transport Police (BTP) said the two employees on board were accounted for without injury, but a number of carriages carrying “large amounts of diesel oil”  derailed and caught fire in the incident.

On Thursday afternoon, the train’s three cars were still alight and people were being asked to remain clear of the area while fire crews attempted to cool them.

Officers declared a major incident and knocked on the doors of houses in an 800-metre exclusion zone, asking around 300 people to move to the nearby Bryn School and Llangennech Community Centre.

People were allowed to return to their homes after 5am on Thursday.

BTP Superintendent Andy Morgan said in a statement at the scene that officers were assisting the Office of Rail and Road and the Rail Accident Investigation Branch to find out what caused the incident.

“What we know is a freight train, carrying large amounts of diesel oil, caught fire and a number of its carriages also derailed. Thankfully, despite the clear danger, no injuries have been reported,” he said.

“The two members of railway staff operating the train were able to raise the alarm and uncouple the locomotive and move it to a safe space.

“The fire was significant due to the quantity of fuel it was carrying and presented a possible danger to the wider community.”

He added: “At this time, the cause of the fire is unknown and, while the fire continues, there is still a substantial risk within its immediate vicinity, so our advice remains for people to avoid the area.”

Richard Felton, head of response for Mid and West Wales Fire and Rescue Service in Carmarthenshire, said 14 pumps and one high volume pump had been used at the height of the fire.

He said: “The incident has now been downscaled to eight pumps, a foam tender and a high volume pump.

“We are left at the moment with three carriages which are being monitored and cooled. They are being temperature checked to make sure they are kept to an acceptable temperature.”

Simon Jenkins, the fire service’s area manager, said: “I would like to say a huge thank you to our crews, who have worked tirelessly to fight and contain the fire at a challenging location and in difficult weather circumstances.

“I would also like to take this opportunity to thank the local community for their support and patience to our crews, during what is a very difficult time for local residence and business.”

Natural Resources Wales, a Welsh Government-sponsored body, said it would only be able to assess the environmental impact of the diesel spill and fire once the situation was “under control”.

Superintendent Ross Evans, of Dyfed-Powys Police, said: “The safety of people living in the area was our immediate priority and an evacuation zone was put in place to minimise the risk of harm.”