The incident happened shortly before the Leeds-Aberdeen service reached Leuchars around 11:30am yesterday.
It caused significant disruption to other trains, with several ScotRail services cancelled.
An industry source said: "There was smoke coming from an engine.
"The fire brigade was called and customers were moved to safety.
"Some passengers were moved to another carriage in case of smoke.
"Then, when they got into Leuchars, the train was terminated and some passengers got onto Virgin Trains coaches. Others got ScotRail services onwards."
Another source said: "I understand the rear power car caught fire.
"The main alternator went up, I am advised."
"The train was later towed by another locomotive back to the Craigentinny depot in Edinburgh."
A spokeswoman for the Scottish Fire and Rescue Service said: "We were called at 11:39am to reports of fire in a compartment of a train at Leuchars train station.
"Three fire appliances were mobilised to the scene.
"Crews arrived to discover the fire had already been extinguished with no casualties reported.
"They ensured the area was made safe before leaving the scene at 1pm."