An Iarnrod Eireann employee who had consumed cannabis caused a 12-tonne locomotive to crash at speed after he mistakenly closed a level crossing.
An investigation into an accident at the Buttevant crossing in Cork last summer found that the worker's co-ordination and concentration "may have been affected" by the illegal drug.
A packed passenger train had passed through the crossing just 40 seconds before the crash.
A report from the Rail Accident Investigation Unit (RAIU), published yesterday, found that on July 2 last the unnamed worker closed a gate at a railway crossing too early, resulting in a track recording vehicle (TRV) -- which travels on the railway line carrying out safety checks -- crashing into the gate while travelling at 64kmh.
The report found the gatekeeper was closing the level crossing as the vehicle arrived at 10.23am.
The RAIU also said there was no safety system in place which would have ensured that gates could not be moved as a train was approaching.
No one was injured in the incident.
"The gatekeeper's co-ordination and concentration may have been affected by the presence of cannabis in his system," the report found.
Iarnrod Eireann has since upgraded safety systems at similar crossings.
The gatekeeper had been passed as competent to operate the level crossing just 10 days before the accident.
He was screened for drugs afterwards, and the company's chief medical officer said the presence of cannabis had "significant implications".
"The apparent failure to carry out all the required checks... prior to closing the level crossing gate to the railway may have been, at least partly, as a result of the presence of this substance in the gate keeper's system," the report added.
Iarnrod Eireann said it tested around 5pc of its 4,200 employees for drugs every year, or more than 200 people, and that none had failed a drugs test.
The employee involved in the incident has since resigned. Gardai were notified of the accident but no prosecution was taken.
An Iarnrod Eireann spokesman added: "All random tests to date have been negative for drugs and alcohol, indicating the commitment and professionalism which exists across our workforce.
"Our policy ensures that as well as random and other testing, there is an awareness and education for employees of issues relating to drugs and alcohol.
"This will ensure the safety of customers and staff alike, and aid us in our goal to prevent any repeat of an isolated incident such as this level crossing accident."