A group of Marin residents have purchased the last remaining locomotive of the once-famous “Crookedest Railroad in the World,” which ran from Mill Valley 8.19 winding miles to the top of Mount Tamalpais.

The group’s plan is to restore the 97-year-old steam engine and to bring it back to Marin County, where it once was the pride and joy of the Mount Tamalpais and Muir Woods Railroad. Then it would be put on display somewhere along the old line to recall the days when tourists flocked by the thousands to ride the scenic railroad and marvel at the views from the top of Tamalpais and the redwoods of Muir Woods.

“The mountain railroad was world famous,” said Fred Runner, who is manager of the nonprofit corporation that purchased engine No. 9. “It really put Marin in the map.”

The line began service in 1896, when a group of local businessmen decided to tap into the early tourist draw to the area by building a scenic railroad. The line had 281 curves, so the promoters called it “the crookedest railroad in the world.” They also built an elaborate hotel near the summit and two more inns along the line.

A branch line was built to Muir Woods in 1907, the year before the redwood forest was made a national monument. “The railroad brought the first tourists to Muir Woods,” Runner said.

The railroad was an immediate success, drawing visitors from all over the world, among them Sir Arthur Conan Doyle, author of the Sherlock Holmes series, and John Muir, who visited the railroad’s hotel in Muir Woods.

The trains were powered by geared steam locomotives, of a type usually used in logging railroads. Business was so good that the railroad bought engine No. 9 brand new from the Heisler Locomotive Works of Erie, Pa., in 1920.

No. 9 ran on Mount Tamalpais until 1924, when the company had a cash-flow problem and sold the engine to the Siskiyou Lumber Co. for $9,750.

By the late 1920s, the mountain railroad was unable to compete with new roads and private automobiles and was dealt a fatal blow when a forest fire devastated Mount Tamalpais in 1929. The line was abandoned a year later and its roadbed turned into a hiking and biking trail.

Meanwhile, No. 9 was put to work on other lumber railroads until 1950, when it was sold to the Pacific Lumber Co. in the Humboldt County town of Scotia. When Pacific Lumber ended its steam train operations, it put No. 9 on display outside company headquarters.

The engine remained there, exposed to the weather, for more than 60 years, until the Scotia Community Services District put it up for auction this year.

Friends of No. 9, the Marin group, bid $56,240 for the engine. The group includes members of Friends of Mt. Tam, the Marin History Museum and others.

Though replicas of the railroad’s unique “gravity cars,” which coasted down the mountain, are displayed at either end of the line, No. 9 is the last piece of original rail equipment remaining. The next step is to restore the engine and move it to Marin, a project that could cost up to $500,000, an amount that would be privately raised.

Runner said contributions can be made to the Mill Valley Historical Society, 375 Throckmorton Ave., Mill Valley, CA 94941.