A fire on a derailed freight train carrying motor diesel and gas oil could burn for several days, it has been claimed.

Two people escaped unhurt after they uncoupled the locomotive from its burning wagons as they passed through Llangennech, near Llanelli, in South Wales, at around 11.20pm on Wednesday.

The cause of the incident is currently unknown with investigators having to wait for the fire affecting three wagons to be extinguished.

There are also fears that diesel spillage into the nearby River Loughor could spell disaster for the local cockle fishery industry, with the Foods Standards Agency advising the closure of shellfish beds in the area’s estuary.

The train, owned by DB Cargo UK, was transporting “large amounts” of diesel between the Robeston oil refinery in Milford Haven and the fuel distribution terminal in Theale, in Berkshire.

Witnesses described hearing a loud bang before seeing the fire, which led to emergency crews being called to the area.

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.

A spokesman for Mid and West Wales Fire and Rescue Service told the PA news agency it was “very difficult to say when the fire will be extinguished” due to the quantity of diesel on the site.

The spokesman added: “We can’t say yes or no to whether it will be a few days.”

DC Cargo UK said its priority was to “maintain the safety of the general public and minimise any environmental damage which may arise from this unfortunate incident”.

It added: “We can confirm that the driver and engineer who were aboard the train at the time were both uninjured and are being supported by the company.”

Aneurin Cox, incident manager for Natural Resources Wales, said it was not currently safe for environmental officers to assess the impact of the diesel spill.

She said: “From our initial monitoring of the wider area, it’s clear that some of the diesel is already making its way into the nearby River Loughor.

“Once it’s safe to do so, we will work with our partners to fully assess the environmental impact and advise Network Rail when the clean-up of the site can begin.

“We will also be keeping local angling and cockling groups informed of the latest situation.”

Another spokesman for the environmental body told PA there were fears the spillage could spread further into nearby waterways and contaminate them, potentially leading to cockle fisheries being temporarily shut down.

A spokeswoman for the Foods Standards Agency said: “We are working with local authorities, Welsh Government, Natural Resources Wales and the Centre for Environment, Fisheries and Aquaculture Science to understand if there are any implications for food safety.

“On a precautionary basis we have given advice to local authorities to temporarily close the shellfish beds in the estuary. This will be kept under review and further advice will be provided as more information becomes available.”

Sim Harris, managing editor of Railnews, said similar accidents involving freight trains carrying fuel were “very rare”.

He told PA: “I can’t think of the last accident involving fuel burning on a train. You’d have to go back to the Second World War, where fires were started by the enemy dropping bombs.

“In peacetime, I can’t think of a previous incident where this type of thing has happened. It’s most unusual.”

British Transport Police 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.

He said: “We have continued to respond to the major incident on the railway line near Llangennech throughout this afternoon, alongside many of our partners.

“Officers are conducting initial enquiries and have now been able to take a look at the train from a safe distance. We await further guidance on when it will be safe for us to fully access the scene.

“Once it’s safe to do so, our colleagues at Natural Resources Wales will also be working to fully assess the environmental impact and advise Network Rail when the clean-up of the site can begin.”

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.”