The incident happened during overnight leaf clearance north of Markinch around 4:25am on 17 October.
The driver and a colleague suffered "minor injuries" when they jumped from the train as it started to roll backwards, the UK Government's Rail Accident Investigation Branch (RAIB) reported.
It has launched an investigation.
The RAIB said the train had run away for about four miles after hitting a fallen tree at 40mph, which damaged its underside and "caused the brakes to be irreversibly released".
It then came to a halt as it travelled uphill before starting to roll backwards, when the train crew radioed an emergency and jumped clear.
The train finally stopped near Thornton North junction after travelling back and forth along a section of track several times.
A RAIB spokesman said: "Prior to the collision, the train had been water jetting leaf debris from the rails.
"The driver saw the tree shortly before impact and applied the emergency brake.
"The train continued to slow following the collision, due to the uphill gradient.
"It came to a rest, but then started to roll backwards.
"Having made an emergency call on the train radio, the two train crew jumped from the train onto the trackside and suffered minor injuries.
The train eventually came to a stop on a low point near to Thornton North Junction, after having oscillated up and down the adjacent track gradients several times."
The RAIB said its investigation would include the design of the train’s braking system, the actions of the train crew and the proximity of other trains on the route.