MORRISTOWN -- A broken-down, 53-year-old locomotive is being saved from the scrap yard, in a real-life version of a popular "Thomas the Tank Engine" story.

The Tri State Railway Historical Society is buying the Alco C-424 locomotive and plans to get it up and running for special events, said Kevin Phalon, the group's vice president.

"It is an engine that has very deep ties locally," Phalon said in explaining the locomotive's significance.

The four-axle, diesel-electric locomotive had rumbled along the Morristown and Erie Railway since 1983, Phalon said, until two broken wheels sidelined it in November.

He said the freight service decided to retire the locomotive, due to its age, and was preparing to scrap it for parts until the rail buffs intervened.

Phalon said his group raised enough money, largely via an anonymous donor, to match what the railway would have gotten for parts.

He declined to disclose the amount.

A phone call to the Morristown and Erie Railway was not immediately returned.

The outcome mirrors the fictional rescue of Hiro, the onetime "master of the railway" restored to his former glory by Thomas, a steam locomotive, and his engine friends on the TV series.

Phalon said the sale will be finalized in a couple of weeks.

First, he said his group is buying the two replacement wheels and that the railway is donating an axle and the labor to repair it.

Once the work is complete, the locomotive -- currently stored on a railway siding in Morristown -- will be transported to a lot in Boonton owned by the United Railroad Historical Society.

The lot was in the news in January after graffiti was found spray-painted on eight historical train cars and windows were broken on two locomotives.

Rob Jennings may be reached at rjennings@njadvancemedia.com. Follow him on Twitter @RobJenningsNJ. Find NJ.com on Facebook.